Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS SQL DB Restore

Status
Not open for further replies.

crmayer

Programmer
Nov 22, 2002
280
US
I have a question about restoring an MS SQL database.
Our current set up is that we have two databases (lme and lme_dev). The lme_dev is our development database. What I am looking to do is update the data in our dev db. I have an option in our software package, where I can export all the data, then import it into the dev db. My problem is that I run acrossed so many records that were updated between me getting tables exported, so they are no longer in sync with each other. I was wondering if I could do a restore on the lme_dev db, and use the db backup and transaction logs from lme? Will that cause any problems? Will it work OK? Or is there a better option for me to get the data updated in our dev db?
 
That idea will work fine.

You'll want to do something like this within Query Analyzer.
Code:
backup database lme_dev to disk='d:\lme_dev.bak'
go
backup database lme to disk='d:\lme.bak'
go
restore database lme_dev from disk='d:\lme.bak'
with move 'lme_data' to 'e:\mssql\mssql\data\lme_dev_data.mdf',
move 'lme_log' to 'e:\mssql\mssql\data\lme_dev_log.ldf'
go
If you have any other files defined for the database you'll need move commands for them as well.

What the code will do is backup the lme_dev database. Then backup the lme database to another file. Then restore the lme database with the name lme_dev while renaming the physical files to the names for the dev names.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top