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
Sql server 2008 SQL Server 2008存储过程中的复合条件_Sql Server 2008_Tsql - Fatal编程技术网

Sql server 2008 SQL Server 2008存储过程中的复合条件

Sql server 2008 SQL Server 2008存储过程中的复合条件,sql-server-2008,tsql,Sql Server 2008,Tsql,您能告诉我存储过程是否允许处理以下复合条件吗: if( ( (select Count(*) from dbo.Membership where EmailID=@emailID) >0) || ((select Count(*) from dbo.Allocation where ResourceEmail=@emailID)>0)) ) 使用或代替| 如果只是检查是否存在,我会使用EXIST

您能告诉我存储过程是否允许处理以下复合条件吗:

if(
    ( (select Count(*) from dbo.Membership where EmailID=@emailID) >0) 
                                  || 
    ((select Count(*) from dbo.Allocation where ResourceEmail=@emailID)>0))
)

使用
代替
|

如果只是检查是否存在,我会使用EXISTS而不是COUNT,因为当它第一次存在时,它将停止,而不是全部计数

IF EXISTS(SELECT 1 FROM dbo.Membership WHERE EmailId = @emailID)
    OR EXISTS(SELECT 1 FROM dbo.Allocation where ResourceEmail=@emailID)
    BEGIN
       -- emailID exists in one of the 2 tables
    END

使用
代替
|

如果只是检查是否存在,我会使用EXISTS而不是COUNT,因为当它第一次存在时,它将停止,而不是全部计数

IF EXISTS(SELECT 1 FROM dbo.Membership WHERE EmailId = @emailID)
    OR EXISTS(SELECT 1 FROM dbo.Allocation where ResourceEmail=@emailID)
    BEGIN
       -- emailID exists in one of the 2 tables
    END

当我试图编译存储过程时,我收到了错误消息。请让我们确切地知道您收到了什么错误消息…..我觉得您的括号不平衡。您有一个额外的
当我尝试编译存储过程时,我收到了错误消息。请让我们确切地知道您收到了什么错误消息…..我觉得您的括号不平衡。您有一个额外的