SA0255 : Consider using extended cursor declaration syntax instead of the ISO syntax

The topic describes the SA0255 analysis rule.

Message

Consider using extended cursor declaration syntax instead of the ISO syntax

Description

The rule checks T-SQL code for cursor declaration statements, which use the ANSI/ISO SQL 92 compliant syntax.

The DECLARE CURSOR statement accepts both ANSI/ISO syntax and the extended T-SQL syntax. The extended syntax is recommended as it supports many more options that the ISO syntax.

How to fix

Rewrite the cursor declaration using the extended T-SQL syntax.

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
13 minutes per issue.
Categories

Design Rules, Code Smells

Additional Information
Example Test SQL
SQL
1DECLARE vend_cursor1 SCROLL CURSOR FOR SELECT * FROM Purchasing.Vendor
2DECLARE vend_cursor2 CURSOR FOR SELECT * FROM Purchasing.Vendor  FOR READ ONLY;
3DECLARE vend_cursor3 INSENSITIVE CURSOR FOR SELECT * FROM Purchasing.Vendor
4DECLARE vend_cursor4 INSENSITIVE SCROLL CURSOR FOR SELECT * FROM Purchasing.Vendor 
5DECLARE vend_cursor5 CURSOR FOR SELECT VendorID, Name, LastName FROM Purchasing.Vendor FOR UPDATE OF Name, LastName

Analysis Results
  Message Line Column
1 SA0255 : Consider using extended cursor declaration syntax instead of the ISO syntax. 1 8
2 SA0255 : Consider using extended cursor declaration syntax instead of the ISO syntax. 2 8
3 SA0255 : Consider using extended cursor declaration syntax instead of the ISO syntax. 3 8
4 SA0255 : Consider using extended cursor declaration syntax instead of the ISO syntax. 4 8
See Also

Other Resources