May 26, 2005 at 11:20 am
I'm trying to apply the following code into a proc I have and wanted to check for the success of the alter database stmt. @@error didn't trip to <> 0 and then tried placing a return status code variable after the execute stmt and received a syntax error.An excerpt of the code follows PEN DB2DefragFETCH NEXT FROM DB2Defrag INTO @DBNamesWHILE @@FETCH_STATUS = 0 BEGIN set @DBNames = '[' + @DBNames + ']' select @cmdstr = 'alter database ' + @DBNames + ' set recovery bulk_logged' print @cmdstr exec @ret_code= (@cmdstr)-- if @@error <> 0 if @ret_code <> 0Any ideas? thkstom.frost@ge.com
May 26, 2005 at 12:47 pm
The formatting's all off so your post is one long line...
however, if you want to check if your code is successful then @@ERROR should return 0.
If you have several statements in your proc, it's always good practice to capture this in a local variable.
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply