Such
Such

Reputation: 285

Incorrect syntax near delete expecting select or '('

I'm trying to make a stored procedure, but I get this error 'incorrect syntax near delete expecting select or '(''

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

Upvotes: 1

Views: 3064

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269633

The syntax for if does not use parentheses.

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;

Upvotes: 3

Related Questions