Formats and stores a series of characters and values in the string output parameter. Each format argument is replaced with the corresponding argument.
xp_sprintf {string OUTPUT, format}
[, argument [,...n]]
0 (success) or 1 (failure)
xp_sprintf returns this message:
The command(s) completed successfully.
Execute permissions default to the public role.
This example uses parameter to create an INSERT statement.
DECLARE @ret_string varchar (255)
EXEC xp_sprintf @ret_string OUTPUT, 'INSERT INTO %s VALUES (%s, %s)', 'table1', '1', '2'
PRINT @ret_string
Here is the result set:
INSERT INTO table1 VALUES (1, 2)
xp_sscanf | System Stored Procedures (General Extended Procedures) |