I downloaded SQL Server Management Studio to my laptop at home. I don't have a database as it is my personal PC. Is it possible to connect to a .mdf
file and do SQL querying in that ?

- 732,580
- 175
- 1,330
- 1,459

- 33
- 5
-
To use a `.mdf` database file, you **must have** SQL Server (the database **engine** - not just the GUI management tool) installed. – marc_s Feb 24 '18 at 15:49
1 Answers
Let's say someone gives you an MDF file of which that's the only database file other than the log file. Can you "connect" to it?
Yes...
Let's say the .MDF file is here: D:\SQL\MSSQL12.MSSQLSERVER\MSSQL\DATA\DatabaseMDF.mdf
In SSMS, connect object explorer to your SQL Server. Right click the Databases folder, and select Attach Database. Add the file, D:\SQL\MSSQL12.MSSQLSERVER\MSSQL\DATA\DatabaseMDF.mdf. Verify that you have legal paths in the database details sub pane under the Databases to attach sub pane. Also, in the database details sub pane, remove the log file you do not have. Click OK... and you have the DB available.
You will need SQL Server installed and running as well. Just SSMS (SQL Server Management Studio isn't enough). You can download from here...
https://www.microsoft.com/en-us/download/details.aspx?id=42299 Windows 7
https://www.microsoft.com/en-us/download/details.aspx?id=55994 Windows 10

- 323
- 1
- 16