****SQL Server related question.
I have a table in which one of the columns (col1) holds a string, like: 1,2,3,4,5,6,7,8,9,10
I am passing an int value (@.intValue) to the sproc.
What I want to be able to do is query the table like...
SELECT * FROM myTable where @.intValue ... is in col1
Any ideas?
Thanks a lot!!!!you can do something like
SELECT * FROM myTable WHERE col1 LIKE '%' + convert(varchar,@.intValue) + '%'
hth|||Thanks for the response ndinakar!
I tried your suggestion...
It does work...to a point. However... in my concatenated string, it is a possibility that I will have something that looks like this.
3,4,5,34,6,21
Then, when I query this table...say I am looking for '2' ...it returns the record with 21 in it.
Any other ideas about how I can go about this? I am thinking that I might have to break this concatenated value into separate columns.
Thanks for the reply. I greatly appreciate it!|||same approach, but you need to insure you have leading and trailing seperators
from this:
3,4,5,34,6,21
to this:
,3,4,5,34,6,21,
now you search for %,val,%
or in your example ,2, which wont match ,21,|||Thanks a lot! That works great...exactly what I was looking for.

No comments:
Post a Comment