I am trying to query a table that has values separated by commas as follows:
SELECT ID, NAME,FULLNAME,STATUS,STORE
FROM EMPLOYEE
WHERE STORE IN (SELECT '''' + REPLACE('001,002',',',''',''') +'''')
ORDER BY STORE
when I run the query above, it produces no results, but when I run it like this:
SELECT ID, NAME,FULLNAME,STATUS,STORE
FROM EMPLOYEE
WHERE STORE IN ('001','002')
ORDER BY STORE
I get like 500 records.
And when I try this:
SELECT ('''' + REPLACE('001,002',',',''',''') +'''')
I get the result '001','002'
so my question is, why the first script does not work, and produces no results?
Is there something I must add to the script for it to work?
please advise.