How to restore SQL Server 2008 R2 database to newly installed SQL Server 2008 R2 instance? Our SQL database server recently suffered a serious OS failure and had to be reinstalled from scratch. We are now attempting to associate the restored database and transaction log files into the new instance of SQL Server.

Our backups are up to date and contain the following two files:


Database.mdf (Primary data file: 170 MB)
Database.ldf (Transaction log file: 837 MB)


I know this is quite a basic question but I believe it is not a duplicate, is relevant and could be of great value to anyone browsing this site looking for similar answers.

The server is running SBS 2003 SP2 (x86).

Please let me know if I need to update this question with more information.
You can use SQL Server Management Studio and attach the database using GUI as described here.

Or using T-SQL, change the path to your drive &amp; folder accordingly.

CREATE DATABASE MyDatabase
    ON (FILENAME = 'D:\MySQLServer\Database.mdf'), 
    (FILENAME = 'D:\MySQLServer\Database.ldf') 
    FOR ATTACH;


More at http://msdn.microsoft.com/en-IN/library/ms176061(v=sql.105).aspx.

The SQL Server Service Account needs read/write permission to those folders used to store the database files.

More reading on security and permission required at msdn.