I have been asked to look into why a stored procedure is failing. The problem is that the application gets an error that a temp table doesn't exist. Here is the code with the problem (my comments in blue, contents were changed to protect company information):
FETCH NEXT FROM @cursor INTO @ID, @Name IF @@FETCH_STATUS <> 0 This doesn't make sense, nor does the next WHILE statement. It says if there are records in the cursor (which is SELECT * FROM a temp table), drop the temp table, get rid of the cursor, raise an error that something couldn't be found. BUT IT...
This is my first post. Hopefully I'll have some good information to post here soon.