Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Howto split a data stored in a table in Sql server?
I want to split the data stored in table with semicolon and then insert the same to a temporary table and then filter based on the data split.

What I have tried:

I want to split the data stored in table with semicolon and then insert the same to a temporary table and then filter based on the data split.
Posted
Updated 13-Jun-16 2:20am
Comments
PIEBALDconsult 13-Jun-16 1:36am    
SQL is not good at that, so you're generally better off not trying. Yet there are ways if you really need to.
Please use "Improve question" to add examples.
And how many such values are involved?
Tomas Takac 13-Jun-16 1:52am    
You didn't try anything. Next time please try to google at least. Here are some articles on codeproject that may be helpful:
T-SQL: Most Practical Split Function[^]
Split Any Delimited String in SQL[^]
Split function in SQL[^]
Maciej Los 13-Jun-16 1:55am    
Post it as an answer.

1 solution

generally store data in DB table with ',' separated is not a good practice. it's not follow normalization rule. it's ok . now, solution is

select * from tbl  (','+ RTRIM(tblcolumn) +',') like '%,'+ condition +'
 
Share this answer
 
Comments
CHill60 13-Jun-16 8:10am    
There is at least a WHERE missing from this solution ... at the moment it is just gibberish. You might want to update it.

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