Het volgende werkt -
DECLARE @A VARCHAR (100)= '4,5,6'
DECLARE @B VARCHAR (100)= 'RXXXXXX'
DECLARE @RETURN_VALUE BIT = 1 --DEFAULT 1
SELECT items
INTO #STRINGS
FROM dbo.split(@A,',')
IF EXISTS(SELECT 1 FROM #STRINGS S WHERE CHARINDEX(items, @B) > 0)
SET @RETURN_VALUE = 0
PRINT @RETURN_VALUE
DROP TABLE #STRINGS
U kunt ook BEVAT gebruiken in plaats van CHARINDEX -
IF EXISTS(SELECT 1 FROM #STRINGS S WHERE CONTAINS(items, @B))
SET @RETURN_VALUE = 0