Microsoft SQL Server 2008中的多值参数
我正在尝试将多个值传递给SQLServer2008中的默认参数 以下是我所拥有的:Microsoft SQL Server 2008中的多值参数,sql,sql-server-2008,Sql,Sql Server 2008,我正在尝试将多个值传递给SQLServer2008中的默认参数 以下是我所拥有的: Declare @PInactive Int Set @PInactive = Case When @PInactive is null Then (0 , 1) Else @PInactive End Select ClientID ,PInactive From #Client Where PInactive in (@PInactive) 给我一个关于(0,1)的错误-声明
Declare @PInactive Int
Set @PInactive = Case When @PInactive is null Then (0 , 1) Else @PInactive End
Select
ClientID
,PInactive
From
#Client
Where
PInactive in (@PInactive)
给我一个关于(0,1)的错误-声明不正确的语法。我还尝试了在0和1之间使用单引号,但没有成功
如有任何建议,将不胜感激。我需要在这个查询中使用其中的许多
谢谢,
Scott不能有多值int变量。但是,您可以将表变量设置为int
DECLARE @PInactive TABLE (State INT);
IF NOT EXISTS (SELECT 1 FROM @PInactive) INSERT INTO @PInactive (State) VALUES (0),(1);
Select
ClientID
,PInactive
From
#Client
Where
PInactive in (SELECT State FROM @PInactive)