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 2008 Forums
 Transact-SQL (2008)
 Automated copy of database

Author  Topic 

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-18 : 10:16:25
Hi all,

I have a test database on server 1 which needs to be updated to be an exact duplicate of the same database on server 2. I would like for this to be automated. I know that I can use the export/import wizard to pull over individual tables, but what is the best way to make a copy of one database to another? The test database is already populated with data so I won't need to recreate it, just simply update it to contain all the data in the original database.

Thanks for your help.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-18 : 10:24:03
Have you tried backup and restore options?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-18 : 10:28:34
That seems to work for databases on the same server, but my db's are on different. And plus, how would I automate it as opposed to me running it manually?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-18 : 10:33:23
quote:
Originally posted by fralo

That seems to work for databases on the same server, but my db's are on different. And plus, how would I automate it as opposed to me running it manually?


You can scehdule it as a job and use UNC path to copy to another server

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-18 : 10:47:30
Thanks. Now I just have to figure out the sql commands to do this. Would this involve 2 steps: the BACKUP and RESTORE commands? Like this..

BACKUP DATABASE test TO DISK = <destination_path>

RESTORE test FROM DISK = <source_path>
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-20 : 09:47:44
quote:
Originally posted by fralo

Thanks. Now I just have to figure out the sql commands to do this. Would this involve 2 steps: the BACKUP and RESTORE commands? Like this..

BACKUP DATABASE test TO DISK = <destination_path>

RESTORE test FROM DISK = <source_path>


Yes you need to use both of them

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -