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.
Author |
Topic |
joriz
Starting Member
2 Posts |
Posted - 2004-06-18 : 19:01:09
|
I have 2 databases called UC_MAIN and UC_DEV. They are exactly the same except for the name of course. i wanna backup the data/logs from the uc_main and restore it to uc_dev. Im having all sort of problems. I tried restore database with replace, MOve..it didnt work..anybody has the step by step tsql that do this.i know i can do DTS. but i wanna do it using tsql first.please help..TIA |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-18 : 19:08:34
|
BACKUP DATABASE uc_mainTO DISK = 'F:\MSSQL\BACKUP\uc_main.BAK;WITH INITRESTORE DATABASE uc_devFROM DISK = 'F:\MSSQL\BACKUP\uc_main.BAK'WITH MOVE 'uc_main_data' TO 'F:\MSSQL\BACKUP\uc_dev_data.MDF',MOVE 'uc_main_log' TO 'F:\MSSQL\BACKUP\uc_dev_log.ldf',REPLACEYou just need to figure out which logical names to use in the WITH MOVE option. Use RESTORE FILELISTONLY for this.Tara |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-18 : 19:13:12
|
--This will give you the name of the logical files on the backup file.RESTORE FILELISTONLYFROM DISK = 'file.bak'--You then need to restore using both replace and move.RESTORE database_nameFROM DISK = file.bakWITHMOVE 'logical_file_data' TO 'file.mdf',--logical_file_data is the data file from RESTORE FILELISTONLY.--file.mdf is the .mdf file for the database.MOVE 'logical_file_log' TO 'file.ldf',--logical_file_log is the log file from RESTORE FILELISTONLY.--file.mdf is the .ldf file for the database.REPLACEMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
|
|
joriz
Starting Member
2 Posts |
Posted - 2004-06-18 : 19:30:05
|
thanks..guys..it works sweet! |
|
|
|
|
|