Click or drag to resize

SA0151 : Statements appear after procedures main BEGIN/END block. Possible missing GO command

The topic describes the SA0151 analysis rule.

Message

Statements appear after procedures main BEGIN/END block. Possible missing GO command

Description

The rule checks for stored procedures, which have their main code enclosed in BEGIN/END block, but also have other statements appearing after this block.

It is possible that a GO end of batch signaling command is missing and the statements in the script following the procedure are included by accident in the procedure's body.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1ALTER PROCEDURE dbo.FooGetTableA
 2    (
 3    @Parameter varchar(4)
 4    )
 5AS
 6BEGIN
 7    SELECT Column1 
 8    FROM dbo.TableA
 9    WHERE Column2 = @Parameter
10END
11
12EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Some description for the procedure.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'FooGetTableA'

Analysis Results

 MessageLineColumn
1SA0151 : Possible missing GO statement. Statement appears after procedure's FooGetTableA main BEGIN/END block.120
See Also

Other Resources