xp_sprintf (Transact-SQL)

APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

Formats and stores a series of characters and values in the string output parameter. Each format argument is replaced with the corresponding argument.

Topic link icon Transact-SQL Syntax Conventions


xp_sprintf { string OUTPUT , format }  
     [ , argument [ ,...n ] ]  


Is a varchar variable that receives the output.

When specified, puts the value of the variable in the output parameter.

Is a format character string with placeholders for argument values, similar to that supported by the C-language sprintf function. Currently, only the %s format argument is supported.

Is a character string that represents the value of the corresponding format argument.

Is a placeholder that indicates that a maximum of 50 arguments can be specified.

Return Code Values

0 (success) or 1 (failure)

Result Sets

xp_sprintf returns the following message:

The command(s) completed successfully.


Requires membership in the public role.

See Also

System Stored Procedures (Transact-SQL)
General Extended Stored Procedures (Transact-SQL)
xp_sscanf (Transact-SQL)