Sometimes we need to restore a database off someone else’s BAK file. If you dont do it often or have never done it, then here is how.
I like SQL Management Studio.
- Create a new database with the name you want.
- Right click that database and then go to Tasks -> Restore -> Database
- In the new dialog, enter your database name, and select the backup file at the bottom.
— Now here comes the trick — - Go to the options tab and select “Overwrite the Existing Database”, and select new paths to restore the files to (usually your default SQL folders).
The script to do this can be generated and here it is:
RESTORE DATABASE [q2g_dev]
FROM DISK = N’D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\q2g_live MS SQL 2005.bak’
WITH FILE = 1,
MOVE N’quip2go_Data’ TO N’D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\q2g_dev.mdf’,
MOVE N’quip2go_Log’ TO N’D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\q2g_dev_log.ldf’,
NOUNLOAD,
REPLACE,
STATS = 10
GO
Enjoy. Use your database names instead of mine





