Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help understanding an insert statment please

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2013-09-27 : 11:44:48
Hi,
I have been tasked to rewrite an old stored proc to work with a new DB schema and going though the old proc to try to understand what it does I ran across an insert statement I had not seen before.

insert @LocaleList
select cast(text as int)
from fn_spr_parse_string(@LocaleMulti, ',')


I know it is inserting into the varable @LocaleList (which is a temp table with a single coluimn called LocalID of INT). What I can't figure out is why there is only a cast statement in the select and what the fn_spr_parse_string is (hidden proc maybe?) @LocaleMulti is a comma sperated list that is feed into the extisting proc.

I am kind of thinking by some maject it is just splitting the @LocaleMulti based off ',' but I am not 100% on that or how it would be doing so if it is.

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-27 : 11:55:52
fn_spr_parse_string is probably a string splitter function that takes two parameters - the string to be split and the delimiter. If you open up object explorer in SSMS and navigate down to databasename -> Programmability -> Functions -> Table-valued Functions, you should see it.

The function is returning a column named text as a string; the cast is casting that column to int.
Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2013-09-27 : 11:57:12
Thanks, I did fine it under the functions section and it does look to do the splitting.

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia
Go to Top of Page
   

- Advertisement -