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
 Old Forums
 CLOSED - General SQL Server
 looping comma separated string

Author  Topic 

dcobb
Yak Posting Veteran

76 Posts

Posted - 2003-05-23 : 08:21:40
I have a string as follows: '1,3,7,9' which I pass to a stored procedure. I would like to be able to split the string into an array of only numbers, then loop each item in the array and insert each number into a new row.

E.g.

insert into pubs (id) values (array[a]) where name = 'fred'.

Any ideas?

Regards

Dave


Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-05-23 : 09:10:49
Parsing CSV Values Into Multiple Rows
Passing a CSV or Array to a Stored Procedure

Jay White
{0}
Go to Top of Page

dcobb
Yak Posting Veteran

76 Posts

Posted - 2003-05-23 : 09:21:36
Thanks

Dave

quote:

Parsing CSV Values Into Multiple Rows
Passing a CSV or Array to a Stored Procedure

Jay White
{0}



Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-05-23 : 10:04:47
I would also suggest reading this thread.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830

See Jeff's udf method

Go to Top of Page
   

- Advertisement -