How to backup a database.

  • Thread starter Thread starter ad
  • Start date Start date
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?
 
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.
 
Back
Top