By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

Split Function in Sql stored procedure

Soniad
P: 66
Hello,

I am new to stored procedure, i am passing one parameter to stored procedure (comma seperated). i want to know how to split this variable inside stored procedure.

Expand|Select|Wrap|Line Numbers
  1. Sample :
  2.  
  3. Exec mystoreproc  '1,2,3,4,5'
i want to split '1,2,3,4,5' in commas and to loop through these numbers.
how to do..???

Regards,
"D"
Jan 24 '09 #1
Share this Question
Share on Google+
4 Replies


ck9663
Expert 2.5K+
P: 2,878
Depends on what you're going to do with it. What do you have so far?


-- CK
Jan 24 '09 #2

Soniad
P: 66
@ck9663
I want to split these numbers (1,2,3,4,5) and want to insert this id one by one in a table. if it was in vbscript or javascript i wud have done it..but don't have any idea how to do in stored procedure..the only idea i have is that by using CHARINDEX it cud be done.but how??
any suggestion please..


Regards,
"D"
Jan 25 '09 #3

ck9663
Expert 2.5K+
P: 2,878
Use this technique.


-- CK
Jan 25 '09 #4

Soniad
P: 66
@ck9663
Thanks for ur assistance.

Regards,

"D"
Jan 31 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.