Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

SQL – Backup Methods, Some Cool Scripts Expand / Collapse
Author
Message
Posted Sunday, November 16, 2008 3:02 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, November 1, 2013 8:49 AM
Points: 79, Visits: 1,328
philcart (11/16/2008)
You really only need to check @@FETCH_STATUS = 0, that indicates that a row was successfully fetched.



I would say this actually depends on the type of cursor you open. There are 3 possible statuses in a fetch for a reason. So if you only check for 0 with certain cursor types you will possibly miss rows after a -2 status is returned by quitting before trying fetches on rows that are after the row which returned the -2 status. I believe static cursors would probably be fine to check only 0. But dynamic cursors will require you to check the possibility of a -2 @@FETCH_STATUS.

Note that Etienne_Lemire states there was -2 status.:
Etienne_Lemire (11/14/2008)


I did some debug of the script with the cursor, sometime it ends before the end when the "fetch next" returns some blanks instead of the DB name, with the fetch_status = -2
Post #603375
Posted Monday, November 17, 2008 7:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 13, 2014 8:27 AM
Points: 7, Visits: 133
Hi,

I tried what Adam told me and it works much better now. Now, if a fetch returns -2, the cursor moves to the next db, there will be only one db backup missing instead of all the remaining ones.

It looks like the "MASTER..Sysdatabases" table is altered often so maybe I will try to use the static cursor and I guess it will resolve the problem.

Thank you Adam!

Post #603645
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse