Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Suppose @
@id Varchar(50)='12,1,2,5'
how to separate Each Value ?? in Sql
Posted
Comments
Krunal Rohit 21-Feb-14 6:56am    
You want to select the records based on this comma separated values ?
-KR
k07 24-Feb-14 4:47am    
Actually this varchar value is passed as a parameter.I got this comma separated value by appending the id of checked radio button list.I want to separate each value in my query ....pls help...or suggest if there is any other method to get the checked radio list value?

Bala Selvanayagam 21-Feb-14 6:56am    
If could could tell us why do you want to separate into each numbers and the intended usage then it may be helpful to suggest something
k07 24-Feb-14 4:48am    
Actually this varchar value is passed as a parameter.I got this comma separated value by appending the id of checked radio button list.I want to separate each value in my query ....pls help...or suggest if there is any other method to get the checked radio list value?
Bala Selvanayagam 24-Feb-14 6:20am    
Hello,

AS explained below by "OriginalGriff", if you are going to use in a sub query you do not need to separate each value.

You can get away without separating (which can slow down the query) most of the time and you need to let us know exactly what is your intended usage, if you needs a solution

1 solution

Have a look at this: Using comma separated value parameter strings in SQL IN clauses[^] - it explains how to do it for use in an IN clause, but the principle is the same regardless of what you are trying to achive with the CSV string.
 
Share this answer
 
Comments
k07 24-Feb-14 5:00am    
Thanks for your support...
OriginalGriff 24-Feb-14 5:09am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900