I have this string that i am getting from .net application A,B,C,D,E,F,
I wanted to write a sql select statement like
set @string = \'A,B,C,D,E,F\'
I think, the easiest way is as below,
Option1:
set @string = '''A','B','C','D','E','F'''
Exec ('select * from tbl_test
where tbl_test.code in ('+@string+')')
Option2:
set @string = '''A','B','C','D','E','F'''
DECLARE @SQL NVARCHAR(MAX)
SET @SQL='select * from tbl_test
where tbl_test.code in ('+@string+')'
exec sp_executesql @SQL;