Monday, April 23, 2012

Move SQL Server 2008 Express Database

We came across a scenario where we needed to move SQL Express 2008 Database from one computer to another computer. Posting the steps for the same , hope it helps your requirement at some stage!!
A.      Go to SQL Server.  Open SQL Server Management Studio.

B.      Click on New Query and execute the below command.

               Backup Database YourDatabaseName TO Disk='D:\yourbackupfilename.bak'




  

C.      Copy the backup file to target machine

D.      On target machine open SQL Server Management Studio.

E.      Click on New Query and execute the below command.

RESTORE FILELISTONLY FROM DISK='D:\yourbackupfilename.bak' 

This will give the Logical Data and Log File Name to be used for restore command.



F.       Click on New Query and execute the below command.
RESTORE DATABASE Merckcontacttesting
FROM DISK='D:\yourbackupfilename.bak'
WITH MOVE'YourLogicalDatafileName' TO 'D:\ yourdatabase.mdf',
MOVE 'YourLogicalLogFilename' TO'D:\yourdatabase_log.ldf'
            
              Then Refresh the database as shown below and you will see your new database created.


                    Also see the databse mdf and ldf file created at the specified location

 
                    Exit the SQL Management Studio without saving the Query. And use the database moved as required.

No comments:

Post a Comment

Azure Policy support for remediating tags for existing resources

Use Azure policy to remediate tags for existing resources. https://azure.microsoft.com/en-us/updates/azure-provides-at-scale-tags-managem...