| title | xp_sprintf (Transact-SQL) | ||
|---|---|---|---|
| description | Formats and stores a series of characters and values in the string output parameter. | ||
| author | markingmyname | ||
| ms.author | maghan | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server]
Formats and stores a series of characters and values in the string output parameter. Each format argument is replaced with the corresponding argument.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
xp_sprintf { 'string' OUTPUT , 'format' }
[ , 'argument' [ , ...n ] ]
[!INCLUDE extended-stored-procedures]
A varchar variable that receives the output.
When OUTPUT is specified, this option puts the value of the variable in the output parameter.
A format character string with placeholders for argument values, similar to the values supported by the C-language sprintf function. Currently, only the %s format argument is supported.
A character string that represents the value of the corresponding format argument.
A placeholder that indicates that a maximum of 50 arguments can be specified.
0 (success) or 1 (failure).
xp_sprintf returns the following message:
The command(s) completed successfully.
Requires membership in the public role.