Declare @ForeceId sql_variant SET @ForeceId='37,38'exec('Select * from MyTable where Id in('+@ForeceId)
exec('select * from MyTable where Id in('+@ForeceId+')')
Declare @ForeceId sql_variant SET @ForeceId='37,38'select * from MyTable where charindex(','+cast(id as varchar)+',',','+cast(@ForeceId as varchar)+',')>0
Declare @ForeceId sql_variant SET @ForeceId='37,38' select * from MyTable where charindex(id,@ForeceId)>0
SET @ForeceId='37,38'exec('Select * from MyTable
where Id in('+@ForeceId)
SET @ForeceId='37,38'select * from MyTable where charindex(','+cast(id as varchar)+',',','+cast(@ForeceId as varchar)+',')>0
SET @ForeceId='37,38'
select * from MyTable
where charindex(id,@ForeceId)>0