How to backup a database.

A

ad

I want to use program to backup a database.
My idea is:
1. deattach the database.
2. copy the .mdf and .ldf files to another place.
3. attach the database.

How can I deattach/attach a database. I think it will be done with SQL, how
can I implement it?
 
W

W.G. Ryan MVP

I'd just create a job that does this. The commands for each of these are in
Books Online.

To detach, sp_detach_db and sp_attach_db respectively. You can use
xp_cmdshell to copy the files. Just create a job that does these.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top