System.Data.SqlClient.SqlException: A severe error occurred on the current command.

Posted: 2009-01-22 in .Net
Tags:

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

I had written a rather large TSQL query that was used as a single query by a C# program. The query had been tested directyly on the server for about 3 days with no issues. When I moved the TSQL query to the C# program it returned the above exception message about 33% of the time. Even when no rows were returned.

The solution: I had used a INTO #tempTable which created a temp table (derrrrr). I replace this with a DECLARE @tempTable Table(id int, …. ). I never received the error again. So the moral is temp tables just got a whole lot mroe ugly. dont use them.

And YES! I did do a pre check on the tables existance, I did do a drop table after I had finished playing with it (if it existed).

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s