I need your help. I recently came across extended stored procedure xp_sscanf. After reading a lot about it and searching online, I could not figure out how and where in real world, I will use this function.
Microsoft documentations suggest that this extended stored procedure reads data from the string into the argument locations specified by each format argument. I still do not get it. I know it is very similar to C function but again I am not sure where in the real world I will use this function. Here is the demonstration of how this function works.
Following example is an enhanced version of the example provided on MSDN.
DECLARE @valueb VARCHAR(20), @filename VARCHAR(20), @message VARCHAR(20) EXEC xp_sscanf 'sync -b123 -fauthors10.tmp -rrandom', 'sync -b%s -f%s -r%s', @valueb OUTPUT, @filename OUTPUT, @message OUTPUT SELECT @valueb, @filename, @message
The above query will return us following result:
-------------------- -------------------- -------------------- 123 authors10.tmp random
Here is the result set.
You can see how xp_sscanf retrieves the parameters from the string and returns as an output. However, I am still not sure where I will use this feature in real world scenarios. Any insight and or guidance will be helpful.
Reference:Â Â Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com)