Cannot specify both READ_ONLY and FOR READ ONLY on a cursor declaration.

Error Message:
Msg 1058, Level 15, State 1, Line 1
Cannot specify both READ_ONLY and FOR READ ONLY on a cursor declaration.

Severity level:
15.

Description:
This error message appears when you try to use both in the error message mentioned options in a cursor declaration.

Consequences:
The SQL statement cannot be parsed and further execution is stopped.

Resolution:
Errors of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. You must remove one of the two options.

Versions:
All versions of SQL Server.

Example(s):
USE Northwind
GO
DECLARE myCursor CURSOR READ_ONLY FOR
SELECT *
  FROM Northwind.dbo.Orders
  FOR READ ONLY
OPEN myCursor
FETCH NEXT FROM myCursor
DEALLOCATE myCursor

Remarks:
In the above example we try to declare a cursor with both options set. This raises the error.

]]>

Leave a comment

Your email address will not be published.