删除附近的语法不正确期待select或'('

时间:2013-08-17 11:05:26

标签: sql

我正在尝试制作存储过程,但是我收到此错误'错误的语法接近删除期望选择或'(''

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

1 个答案:

答案 0 :(得分:3)

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;