SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help understanding an insert statment please
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Eagle_f90
Constraint Violating Yak Guru

USA
422 Posts

Posted - 09/27/2013 :  11:44:48  Show Profile  Visit Eagle_f90's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

3661 Posts

Posted - 09/27/2013 :  11:55:52  Show Profile  Reply with Quote
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

USA
422 Posts

Posted - 09/27/2013 :  11:57:12  Show Profile  Visit Eagle_f90's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000