I have this tsql/sp...
declare @IdRange NVARCHAR(255)
SET @IdRange = '1,2,4'
select
FeatureName
FROM
Feature F
JOIN GroupFeature GF ON GF.FeatureId = F.FeatureId
WHERE
GroupId IN ( @IdRange)
The value for @IdRange can vary.
This, when executed will fail.
I could use dynamic SQL and execute it all as string but I just want to explore if there is an alternative?
I have now tried this:
declare @IdRange NVARCHAR(255)
SET @IdRange = '1,2,4'
select
FeatureName
FROM
Feature F
JOIN GroupFeature GF ON GF.FeatureId = F.FeatureId
WHERE
CHARINDEX(',' + GroupId + ',', ',' + @IdRange + ',') <> 0
and get this:
Argument data type int is invalid for argument 1 of charindex function.