Friday, January 20, 2012

SQL SERVER - Restore Database via T-SQL

Ck logical name with the following query:


Query


RESTORE FILEONLY FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\<My DB>_MSCRM.bak'


Result:
Run the following query:



Query


RESTORE DATABASE [<My DB>_MSCRM]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\<My DB>_MSCRM.bak'
WITH FILE = 1, MOVE N'mscrm' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\<My DB>_MSCRM.mdf',
MOVE N'mscrm_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\<My DB>_MSCRM_log.LDF',
NOUNLOAD, REPLACE, STATS = 10
RESTORE DATABASE [<MY DB>_MSCRM]


Nicola Grillo

No comments:

Post a Comment