SA0274 : The first statement in the script, must be USE statement

The topic describes the SA0274 analysis rule.

Message

The first statement in the script, must be USE statement

Description

The rule checks SQL code and reports when the first statement in a script is not a USE database statement.

How to fix

Move the USE statement at the top of the SQL document.

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.

Effort To Fix
2 minutes per issue.
Categories

Design Rules, New Rules

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
1SELECT 'Hello, DB1!'
2
3
4USE DB1
5
6
7SELECT 'Bye, DB1!'

Analysis Results
  Message Line Column
1 SA0274 : The first statement in the script, must be USE statement. 1 0
See Also

Other Resources