Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Backing Up and Copying

Author  Topic 

Mmats
Starting Member

47 Posts

Posted - 2005-07-08 : 12:42:02
Im writing one query to backup a database and then use xp_cmdshell to copy it to another location. My question is, do I have to worry about the file being copied before it is done backing up, or does sql not execute the next line of code until the backup is finished?

Kristen
Test

22859 Posts

Posted - 2005-07-08 : 13:10:49
If its a stored procedure, or some sort of scheduled script, then Line 2 does NOT start until Line 1 is finished.

If it isn't quite a simple as that have the "Copy" bit RENAME the file first and then copy the renameed file. The Rename will fail if the file is still "in use" - and you could trap that (i.e. checking if you have the New or the Old name after the rename step), WAIT n seconds, and the loop round and try again.

Kristen
Go to Top of Page

Mmats
Starting Member

47 Posts

Posted - 2005-07-08 : 13:35:02
The rename thing is actually a really good idea. Thanks for the tip
Go to Top of Page
   

- Advertisement -