Sunday, June 14, 2015

Restore .bak file using query

--What account are you running the SQL Server engine under? Does that account have access to the location of the backup file.


-- Can you read the file list
RESTORE FILELISTONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER1\MSSQL\Backup\SASDB01062015.bak'
   WITH FILE=1;
GO



-- Is this a valid backup?
RESTORE VERIFYONLY
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\SASDB01062015.bak'
   WITH FILE=1;
GO



-- Simple restore, source and target file names and location are the same
RESTORE DATABASE AdventureWorks2012
   FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\SASDB01062015.bak'
   WITH FILE = 1
   RECOVERY;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.