Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm trying to create a database, NewClientDB, by restoring another database's, OldClientDB, backup, d:...oldclientdb.bak. I've always done this via SQL 2000 Enterprise Manager, but the GUI keeps hanging. I've already created the empty NewClientDB.

Anyone know how to restore the OldClientDB's backup to NewClientDB via script without affecting OldClientDB?

share|improve this question
add comment

migrated from stackoverflow.com Jun 18 '12 at 19:19

This question came from our site for professional and enthusiast programmers.

1 Answer

RESTORE DATABASE [NewClientDB] 
FROM  DISK = N'D:\OldClientDB.bak' 
WITH  FILE = 1,  
MOVE N'OldClientDB_Data' TO N'C:\Data\MSSQL.1\MSSQL\Data\AdventureWorksNew_Data.mdf',  
MOVE N'OldClientDB_Log' TO N'C:\Data\MSSQL.1\MSSQL\Data\AdventureWorksNew_Log.ldf',  
NOUNLOAD,  STATS = 10

Source: BACKUP and RESTORE in SQL Server

share|improve this answer
    
I'm being pedantic, but I think the NewClientDB_Data etc need to be OldClientDB_Data as those will be the names of the files used from the original db. –  Jon Egerton Jun 18 '12 at 21:18
    
@JonEgerton Not pedantic, Correct! Ill update my answer. –  benni_mac_b Jun 18 '12 at 21:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.