Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

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

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.

Upvotes: 13

Views: 91650

Answers (2)

hailinzeng
hailinzeng

Reputation: 995

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

Upvotes: 1

Brad Christie
Brad Christie

Reputation: 101614

.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

Upvotes: 14

Related Questions