Skip to main content
If you are not having the database files (mdf and ldf) files, you can download the stack overflow demo database files.

Method 1: Using SSMS UI

  1. Open object explorer in SSMS and connect to the server.
  2. Right click on the Databases folder and select Attach.
1113_20220405_102326.png
  1. Click Add and select the mdf file and verify the database name and file locations.
1114_20220405_102710.png
  1. Click Ok to create the database.
1116_20220405_104147.png

Method 2: Using T-SQL query

If this query has helped you to solve an issue, you may also like the other T-SQL queries I have posted at blog.rajanand.org