como breviario cultural te dejo la funcion para hacer el IN con una variable(separada por comas, pipes o el caracter que quieras)
Código SQL:
Ver originalCREATE FUNCTION [dbo].[SplitApplication](@applicationid VARCHAR(2000))
RETURNS @RtnValue TABLE
(
Id INT IDENTITY(1,1),
DATA nvarchar(100)
)
AS
BEGIN
DECLARE @Cnt INT, @SplitOn nvarchar(5)
SET @SplitOn = ','
SET @Cnt = 1
While (Charindex(@SplitOn,@applicationid)>0)
BEGIN
INSERT INTO @RtnValue (DATA)
SELECT
DATA = ltrim(rtrim(SUBSTRING(@applicationid,1,Charindex(@SplitOn,@applicationid)-1)))
SET @applicationid = SUBSTRING(@applicationid,Charindex(@SplitOn,@applicationid)+1,len(@applicationid))
SET @Cnt = @Cnt + 1
END
INSERT INTO @RtnValue (DATA)
SELECT DATA = ltrim(rtrim(@applicationid))
RETURN
END
GO
how TO USE :
SELECT * FROM TABLE WHERE DATA IN (
SELECT * FROM SplitApplication('1,1,1,1')
)
como la usarias en tu ejemplo:
SELECT * FROM GRADEDWAGERDETAIL D WHERE IdWager IN (SELECT * FROM SplitApplication(@IdWagerParlay))
saludos!