Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Microsoft SQL Server 2008中的多值参数_Sql_Sql Server 2008 - Fatal编程技术网

Microsoft SQL Server 2008中的多值参数

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)的错误-声明

我正在尝试将多个值传递给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)的错误-声明不正确的语法。我还尝试了在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)