Friday, 13 March 2009

‘Severe error’ in SQL Server 2008

System.Data.SqlClient.SqlException: A severe error occurred on the current command.  The results, if any, should be discarded.

That’s not a very helpful error message!

Googling doesn’t throw up much except for KB article 961283. However after installing Cumulative Update 3 the problem remained, so that wasn’t it.

Narrowing down the problem highlighted a stored procedure using a CURSOR while talking to a linked server.

Re-writing the stored procedure without a cursor gave back a more descriptive error (trying to set a non-nullable column to null!). Now it was easy to fix.

Thanks to Timothy, SQL guru :-) I’ll let him describe how he writes T-SQL that avoids cursors.

No comments: