There are two ways to restore database from .mdf file in SQL Server:
With the help of SQL Server Management Studio
- Open SSMS and go to object explorer of the database engine instance.
- Then right click on the database and select Attach... option.
- Windows appers, then click on Add button Select the .mdf file and click on OK Button.
- Validate the selected files and click OK Button.
Using T-SQL
Login to SQL Server database engine.
Go to New Query Window and use Create database using below query.
CREATE DATABASE OreCal
ON (FILENAME = 'C:\Ore-cal_Data.mdf'),
(FILENAME = 'C:\Ore-cal_Log.ldf')
FOR ATTACH;