How to attach database files and create database in SQL Server?
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
- Open object explorer in SSMS and connect to the server.
- Right click on the
Databases
folder and selectAttach
.
- Click
Add
and select the mdf file and verify the database name and file locations.
- Click
Ok
to create the database.
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