xp_sscanf (Transact-SQL)
Applies to:
SQL Server
Reads data from the string into the argument locations specified by each format argument.
Transact-SQL syntax conventions
Syntax
xp_sscanf { 'string' OUTPUT , 'format' } [ , 'argument' [ , ...n ] ]
Arguments
'string' OUTPUT
The character string to read the argument values from.
When OUTPUT
is specified, string puts the value of argument in the output parameter.
'format'
A formatted character string, similar to the values supported by the C-language sscanf
function. Currently, only the %s
format argument is supported.
'argument'
A varchar variable set to 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_sscanf
returns the following message:
Command(s) completed successfully.
Permissions
Requires membership in the public role.
Examples
The following example uses xp_sscanf
to extract two values from a source string based on their positions in the format of the source string.
DECLARE @filename VARCHAR(20),
@message VARCHAR(20);
EXEC xp_sscanf 'sync -b -fproducts10.tmp -rrandom',
'sync -b -f%s -r%s',
@filename OUTPUT,
@message OUTPUT;
SELECT @filename, @message;
Here is the result set.
(No column name) (No column name)
---------------- --------------------
products10.tmp random
Related content
प्रतिक्रिया
https://aka.ms/ContentUserFeedback.
जल्द आ रहा है: 2024 के दौरान हम सामग्री के लिए फीडबैक तंत्र के रूप में GitHub मुद्दों को चरणबद्ध तरीके से समाप्त कर देंगे और इसे एक नई फीडबैक प्रणाली से बदल देंगे. अधिक जानकारी के लिए, देखें:के लिए प्रतिक्रिया सबमिट करें और देखें