Pages

Wednesday, January 30, 2013

sql server database backup + restore



Backup database:

USE DatabaseName
GO
BACKUP DATABASE DatabaseName
TO DISK = 'C:\dataFolder\db9-18-12.Bak'
GO

1      Copy the .bak file onto the local computer  into c:\dataFolder\
         Open SMS on the local computer
        Run this query to replace the existing database (* this is basic migration. This will drop existing database and replace. If appending data or something else, need to modify the query) – If the database doesn’t exist, remove the REPLACE clause (remove prior “,” also) and the new database will be created from the backup. 

Restore or create new DB:

USE MASTER
GO
RESTORE DATABASE JONDO
FROM DISK = 'C:\dataFolder\db9-18-12.Bak'
WITH
REPLACE
GO

No comments:

Post a Comment