Quantcast
Channel: Scripting Live database to local
Viewing all articles
Browse latest Browse all 5

Re: Scripting Live database to local

$
0
0

Hi,

Seems the same except the other way round: https://technet.microsoft.com/en-us/library/ms188664(v=sql.105).aspx

My personal preference is to just do a backup/restore. Edited but for example I got some inspiration from a prod-dev.sql script :

IF @@SERVERNAME='PROD' backup database XX to disk='\\somewhere\xx.bak' with init
GO
USE master
GO
IF @@servername='DEV'
	RESTORE DATABASE xx FROM disk='\\somewhere\xx.bak' WITH
	MOVE 'xx_dat' TO 'a:\xx.mdf',
	MOVE 'xx_log' TO 'b:\xx.ldf'
GO
USE xx
GO
EXEC sp_change_users_login 'Auto_Fix','xx'

So I load the script on the PROD server and it does the backup and load it on the DEV server and it does the restore and I can do the same again and again at anytime without bothering much. Of course double check the script is ok before doing the first restore.

It also depends which level of control you have on those servers (if this is an hosting company they should have something in place so that you can grab a backup file).


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>