带有变量的SQL CASE子句

时间:2015-07-28 08:08:35

标签: sql sql-server tsql stored-procedures

我收到此错误:

  

' ='。

附近的语法不正确

代码:

WHERE 
     T.[ID] = -9769 
     AND TNS.Active = 1
     AND CASE   
            WHEN T.[StatusID] IN (1,6) 
              THEN (T.[AuditUser_ID] = 2  AND TNX.Actor = 2)
         END

1 个答案:

答案 0 :(得分:0)

WHERE 
     T.[ID] = -9769 
     AND TNS.Active = 1
     AND 1 = CASE   
             WHEN T.[StatusID] IN (1,6) 
             and (T.[AuditUser_ID] = 2  AND TNX.Actor = 2) then 1 else 0
         END