returning result from comma seperated string

Posted by Shoyebaziz123 under Sql Server on 8/6/2012 | Points: 10 | Views : 847 | Status : [Member] | Replies : 2
Hi All,
I have a problem with query
my table is

id header searchstr
1 name1 s,r,d,c,b,a,r
2 name2 a,b,c,d,x,y
3 name3 a,hh
4 name4 s

i want to return all of the row if i send a value 's'

eg. if i sent 'c' then it must be return name1,name2

how can i do that ?




Responses

Posted by: Ranjeet_8 on: 8/6/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
try this
Select * from Table_Name where searchstr  like '%c%'


Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 8/7/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
you have two way!

1. You can use LIKE operator (as "Ranjeet_8" suggested) or
2. Configure Full-Text index on "searchstr" column and use CONTAINS / FREETEXT predicate

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response