Code Analysis

SC005

The procedure grants itself permissions

The procedure grants itself permissions. This may indicate that a GO is missing.

Available in

SQL Prompt

SQL Code Guard

Consider the following:

CREATE PROCEDURE MyProc
AS
     BEGIN
         SET NOCOUNT ON;
     END;
  
GRANT EXECUTE ON MyProc TO PUBLIC;
GO

In the above example, if GO is omitted before the GRANT statement, the procedure will be created with the GRANT statement included as part of its body, and no rights will be granted during script execution. It is very unusual for a stored procedure to legitimately grant rights to itself, which is why this pattern should be flagged.



Didn't find what you were looking for?