Click or drag to resize

SA0107 : Avoid using procedural logic with a cursor

The topic describes the SA0107 analysis rule.

Message

Avoid using procedural logic with a cursor

Description

The rule identifies CURSOR usage inside the code and notifies for cursor declarations.

Review your code and consider using a set-based solution instead of the cursor/iterative solution for the given task.

Scope

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

Parameters
NameDescriptionDefault Value
RuleSuppressMark

Suppress rule reporting a rule violation in case a comment containing the value of this parameter is found close to the source of violation.

IGNORE:SA0107

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules

Additional Information
Example Test Script
1DECLARE vend_cursor CURSOR
2    FOR SELECT BusinessEntityID, Name, CreditRating FROM Purchasing.Vendor
3
4OPEN vend_cursor
5
6FETCH NEXT FROM vend_cursor;

Analysis Results

 MessageLineColumn
1SA0107 : Avoid using procedural logic with a cursor.18
See Also

Other Resources