Last post Nov 24, 2015 11:01 AM by PatriceSc
Nov 24, 2015 07:03 AM|Jack Hunt|LINK
Following is my table.
Now i want to check if column [o1] contains id of column  and same for column  .
Both column data type are nvarchar(max).
Suppose if Column  's value is '4' or '1' then its fullfil criteria.
Resolve using follwing
select * from myTable
Where  in ([o1])
Above syntax not working.
Nov 24, 2015 11:01 AM|PatriceSc|LINK
My understanding is that you want something such as :
WHERE ','+o1+',' LIKE '%,'++',%'
It would give for example ',4,1,' LIKE '%,0,%' which will be true if you have 4 or 1 rather than 0. The extra space you have in your string might be a problem. I would delete it. I'm suing extra comma to avoid '10,2' LIKE '%1%' which is true even if you
have 10 rather than 1.
Using IN doesn't work as it expect a list of comma separated values while '4, 1' is just a single string. You could also a function or XML processing statement to turn this into a real list (or keep it as a list if this is what you have to start with).
If you can try to work with real lists.