Sql-server – New SQL Server 2008 instance, load old instance DB’s

restoresql serversql-server-2008

BACK STORY:
I'm a developer with a local instance of SQL Server 2008 on my workstation. I just recently upgraded my motherboard and found out (much to my dismay) the old motherboard's RAID drivers apparently are not compatible with the new mother board so essentially, I'm unable to use the Windows instance I had with the old motherboard. Luckily I have a full backup of all it's contents.

My problem:
I want to install SQL Server 2008 on my new box but I want to load the old data files. I have quite a few databases I don't want to recreate. I have all the original MDF's and LDB's but no actual SQL Server "backups".

Is there a way I can do this?

Thanks for your help.

Best Answer

You can actually attach a database file.

CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:\PathToDataFile\DataFileName.mdf'), 
    (FILENAME = 'C:\PathToDataFile\LogFileName.ldf')
    FOR ATTACH; 

Modify the paths with the paths to your files. The trick is the FOR ATTACH clause.

You can attach a database by right-clicking on the Databases node then selecting the Attach item.

References:

How to: Attach a Database File to SQL Server Express

Attach a Database