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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BAK File

Status
Not open for further replies.

uncgis

MIS
Apr 9, 2004
58
0
0
US
Does anyone know how to restore a backup file (BAK) to a SQL Server database that was created on another machine.

I have right clicked on the database and went to restore database...I change the file path to my new BAK file and click ok...but SQL Server will not back up the file.

THanks for any comments.
 
You didn't indicate why SQL server wouldn't restore your file (what error message or behavior etc.), so I'm just guessing that this might be the problem:

The BAK file contains the full path of the target location where the database is to be restored. Of course, restoring to a different machine means that information is invalid, so you have to change it. In the OPTIONS tab of the Restore dialog, change the information in the "Restore As" column to indicate the full path and filename of your desired target, both database and log file (two separate rows).


Mike Krausnick
Dublin, California
 
thank you for responding...

That is exactly what the problem was...I did not change the file names.

thanks again for your help
 
Try using a script, then you can play around with some variations like data paths and the like

Code:
RESTORE DATABASE  nameOfDatabase
FROM DISK = 'C:\pathOfBackUpFile\nameOfDatabase.bak'
WITH MOVE 'nameOfDatabase' TO 'C:\fullDataPath\nameOfDatabase.mdf',
	MOVE 'nameOfDatabase' TO 'C:\fullDataPath\nameOfDatabase_log.ldf',
	REPLACE, STATS = 20

nameOfDatabase = the actual name of the db
pathOfBackUpFile = where the backup file resides (this may not be on C:\)
fullDataPath = where your SQL data files reside

When you run the script, if there are any errors, then you'll have a better idea why it doesn't work and you can adjust the script accordingly.


Dale
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top