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)
 Database Backup

Author  Topic 

Torch
Starting Member

20 Posts

Posted - 2005-07-13 : 21:36:04
Can someone tell me how I would write a stored procedure that backs up and restores a database on the same server?

Torch.

Kristen
Test

22859 Posts

Posted - 2005-07-14 : 00:31:25
Have a look at Tara's Blog
http://weblogs.sqlteam.com/tarad/category/95.aspx
or you could use the Backup Maintenance tools in Enterprise Manager

Or are you just trying to copy a database to a new name as a one-off task?

Kristen
Go to Top of Page

Torch
Starting Member

20 Posts

Posted - 2005-07-14 : 04:21:48
I need to put it into a stored procedure as it will be done through an application a large numer of times.

Torch.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-07-14 : 11:31:48
Tara's blog has a good worked example of how to do regular backups using Sprocs; it contains all the "moves" for an equivalent home-brew SProc.

Having said that the BACKUP and RESTORE commands have trillions of options depending on what you want to do - split various tables into different filegroups spread across multiple drive systems for performance; restore to a different phsyical location to the original database backup. That sort of stuff.

Might be an idea to explain in more detail what problem you are trying to solve - someone here will probably have the makings of a solution already built, or failing that a bunch of "suggestions"!

Kristen
Go to Top of Page
   

- Advertisement -