1

我正在尝试创建一个存储过程,但我收到此错误“删除附近的语法不正确,期望选择或”(“”

CREATE PROCEDURE NSP166_DeleteDMSPermission  
 @PermissionID uniqueidentifier  ,
 @FunctionalDetailsId uniqueidentifier
AS  
BEGIN  

if(SELECT count(PermissionID) AS counts FROM NSP166_RolePermissionTrans where PermissionID=@PermissionID)>1
(
delete from NSP166_RolePermissionTrans where FunctionalDetailsId=@FunctionalDetailsId
)END
4

1 回答 1

3

for 的语法if不使用括号。

CREATE PROCEDURE NSP166_DeleteDMSPermission  
 @PermissionID uniqueidentifier  ,
 @FunctionalDetailsId uniqueidentifier
AS  
BEGIN  
    if (SELECT count(PermissionID) AS counts
        FROM NSP166_RolePermissionTrans
        where PermissionID=@PermissionID) > 1
    begin
        delete from NSP166_RolePermissionTrans
            where FunctionalDetailsId=@FunctionalDetailsId
    end
end;
于 2013-08-17T11:07:02.053 回答