Installing a Database in Microsoft SQL Server


If you have the primary database file (.MDF) for your database, you can easily install it via SQL Server Management Studio.

Start by loading up SQL Server Management Studio. Once loaded, right click on Databases in the Object Explorer and select Attach:

Choosing the Attach option from the Database context menu


In the dialog that opens, choose Add.

Protip: Copy the filepath that appears in the new dialog into a Windows Explorer window. Drag the database file into that window to get it to the correct location more easily. Once you’ve done that click the Refresh icon in the Locate Database Files dialog.

Choose the database you wish to open and click OK.

Your database will now appear in the Attach Database dialog. However, a Log File will also be listed however it (most likely) doesn’t exist. If this is the case, you will need to select it and click Remove.

Removing the log file

Once that is complete, click OK and enjoy your new database!