What to use to open an .mdf (SQL Database) file
Asked Answered
R

2

13

I was hoping to be able to open .mdf file. I am using WebMatrix, I can view the queries there. I can read the schema too. But how can I read the file without using WebMatrix. Its SQL Server file not the Comptact edition.

I have searched for web help (Through windows). But all in vain. I will prefer any link or any method to read the basic queries.

Regulus answered 18/8, 2013 at 21:55 Comment(2)
but .sdf is a Compact database...Sextans
Sorry, file format is .mdf. It was my bad!Regulus
S
14

.sdf is, in fact, a Compact Database file (unless you've changed the extension which would be problematic). SQL Server would be .mdf.

SQL Server (.mdf)

You can attach the database to your local SQLEXPRESS instance and view it. An example of attaching it can be found on msdn: How to: attach a Database File to SQL Server Express. Essentially you're calling:

USE [master]
GO

CREATE DATABASE [database_name] ON 
    ( FILENAME = N'C:\Path\To\<database name>.mdf' ),
    ( FILENAME = N'C:\Path\To\<database name>.ldf' )
    FOR ATTACH ;
GO

SQL Compact Edition (.sdf)

The best tool I've found to open them is CompactView.

screenshot

Sextans answered 19/8, 2013 at 0:0 Comment(3)
Sorry It was my bad. I have just edited the file name! Actually I am having two folders one is the folder for App_Data (The one that is in the documents) and the other in C:\. So it just slipped off my mind. SorryRegulus
@AfzaalAhmadZeeshan: No worried; Updated the answer for accommodate for .mdf. best thing to do is just attach it to your local SQLEXPRESS. (A walk-through can be found here)Sextans
Sorry youtube is blocked here! :( Will try to Google it. Anyways thanks :)Regulus
M
1

SysTools SQL MDF Viewer can be used to view the table contents. I tried with the free trial version.

Matty answered 17/7, 2017 at 10:58 Comment(1)
but it cant be used to get or copy something out of itNorthwester

© 2022 - 2024 — McMap. All rights reserved.