SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL – Backup Methods, Some Cool Scripts


SQL – Backup Methods, Some Cool Scripts

Author
Message
Adam Gojdas
Adam Gojdas
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 1429
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

Etienne_Lemire
Etienne_Lemire
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 150
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!

Cool
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search