Print View

Backup and restore a SQL database as a different name on the same server

Issue

When copying a database for development or testing purposes, there are a number of parameters that need to be set in the SQL query.

Resolution

Assuming VCBD is the existing database, and vCenter is the destination database.

Backup query:
BACKUP DATABASE [VCDB] TO DISK = N'D:\Backup\VCDB.bak' WITH COPY_ONLY
GO


Restore query:
RESTORE DATABASE [vCenter] FILE = N'VCDB' FROM  DISK = N'D:\Backup\VCDB.bak' WITH FILE = 1, MOVE N'VCDB' TO N'D:\MSSQL\Data\vCenter.mdf', MOVE N'VCDB_log' TO N'E:\MSSQL\LOG\vCenter.ldf'
GO

References

Products

Microsoft SQL 2005 Express Edition (any)

Created: 7th November 2010
Updated: 7th November 2010

Print View

© 2005-2024 Jamie Morrison