I have a problem with string. I have a variable @Rights which looks like 'ASD,ZXC,QWE,IOP,JKL' What I need to do is use this string in
SELECT * FROM dbo.Example
WHERE Rights IN (@Rights)
Problem is that I need to convert:
'ASD,ZXC,QWE,IOP,JKL'
to:
'ASD','ZXC','QWE','IOP','JKL'
How can I do this?
You can use Dynamic SQL:
LiveDemo
But you should reconsider using Table Valued Parameter instead.
you can create a split function
and after you can convert the string in a temp table
and after you can use it in your query like this
You can try like this:
SQL DEMO