question

anjaliv avatar image
anjaliv asked

A severe error occurred on the current command. The results, if any, should be discarded

I am getting an error "A severe error occurred on the current command. The results, if any, should be discarded." when following command is run. I am using SQL server 2005. The script runs for some time and then gives an error. FETCH name_cur INTO @dbName, @tableName WHILE @@Fetch_Status = 0 BEGIN SET @sql -.... insert into [dbo].[Table1] (obj_name, obj_type) EXEC (@sql) UPDATE [dbo].[Table1] SET db_name = @dbName ,table_name = @tableName WHERE db_name IS NULL FETCH name_cur INTO @dbName, @tableName END CLOSE name_cur DEALLOCATE name_cur I am finding dependent objects on a particular table. I have table names and db names in another table. I am fetching them into a cursor and storing dependency in other table. This is the requirement. And I am not sure why this error is occuring.
sql-server-2005cursordependency
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I am sure it may just be an overlook. But based solely on the query provide, I do not know the rest of it you have not supplied the variables declare @dbname, @ tableName and how they are set. So if you do not have those your @@fetch_status will equal -1 an error.
1 Like 1 ·
Can you show your DECLARE name_cur CURSOR code as well?
1 Like 1 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.