Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 2.01 KB

xp-sprintf-transact-sql.md

File metadata and controls

74 lines (50 loc) · 2.01 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
xp_sprintf (Transact-SQL)
Formats and stores a series of characters and values in the string output parameter.
markingmyname
maghan
randolphwest
05/26/2023
sql
system-objects
reference
xp_sprintf_TSQL
xp_sprintf
xp_sprintf
TSQL

xp_sprintf (Transact-SQL)

[!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

Syntax

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

Arguments

'string' OUTPUT

A varchar variable that receives the output.

When OUTPUT is specified, this option puts the value of the variable in the output parameter.

'format'

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.

'argument'

A character string that represents the value of the corresponding format argument.

n

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

Return code values

0 (success) or 1 (failure).

Result set

xp_sprintf returns the following message:

The command(s) completed successfully.

Permissions

Requires membership in the public role.

Related content