I would like assign this text separated comma to IN. Have you got idea how to do it?
DECLARE @TESTTEXT varchar(200)
SET @TESTTEXT = '101,103,104'
SELECT 1 WHERE '101' IN (@TESTTEXT)
I would like assign this text separated comma to IN. Have you got idea how to do it?
DECLARE @TESTTEXT varchar(200)
SET @TESTTEXT = '101,103,104'
SELECT 1 WHERE '101' IN (@TESTTEXT)
use dynamic SQL
DECLARE @TESTTEXT varchar(200)
SET @TESTTEXT = '101,103,104'
exec('SELECT 1 WHERE ''101'' IN ( ' + @TESTTEXT + ')')
Use LIKE:
select 1 where ',' || @TESTTEXT || ',' like '%,101,%'
The extra commas are there to handle first and last item in list.
||
is ANSI SQL for concat
, perhaps tsql has other notation?