Published 16 November 2017
Issues to do with the SQL script and not the SQL itself.
GO has nothing to do with SQL and is not interpreted by SQL Server. It signals the end of a batch on the client (e.g. SSMS) in order to ensure that several batches can be sent from one file or script.
Many editing tools will get confused if the last line in a text file is not terminated with a newline or carriage return / new line combination.
It is unusual to need to jump between database contexts in the middle of a batch, though it is allowed.
There is a
-- TODO Task... comment left in the code.
This rule also matches bug, fix and warning comments left in code.
The procedure grants itself permissions. This may indicate that a GO is missing.
Consider the following:
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.
The EOL marker sequence is not the expected CR/LF.