SDF File Documentation
Summary
An .sdf file is most commonly a SQL Server Compact (SQL CE) database: a single-file, embedded database that a Windows or .NET application uses to store its data. SQL CE reached end of support in 2021, but you can still read .sdf databases with free tools such as CompactView or the SQL Server Compact Toolbox. It is a binary database, so a text editor shows only gibberish. The same extension is reused by an unrelated plain-text chemical Structure-Data File and by some spatial-data tools, so check the contents if the file is not a database.
Technical details
| Feature | Value |
|---|---|
| Full name (primary) | SQL Server Compact Database File |
| File extension | .sdf |
| MIME type | application/octet-stream |
| Format type | Single-file embedded relational database (binary, page-based) |
| Developer | Microsoft Corporation |
| Category | Database file |
| Introduced | 2005 (SQL Server Mobile / Compact Edition) |
| Last release | SQL CE 4.0 (2011) |
| End of support | 13 July 2021 (no successor) |
| Maximum size | 4 GB per database file |
| Magic number | No officially published signature; proprietary binary |
| Human-readable | No — binary; Notepad shows gibberish |
| Encryption | Optional password-protected / encrypted databases |
| Free viewers | CompactView, SQL Server Compact Toolbox (ErikEJ) |
| Migration targets | SQLite, LocalDB (Microsoft’s recommended successors) |
| Other meanings of .sdf | Chemical Structure-Data File (text); spatial/export data (Autodesk FDO) |
| Related extensions | .mdf, .mdb, .accdb, .db, .sqlite, .dbf |
What is an sdf file?
The extension .sdf is generic enough that it has been called a “standard data file”, but in practice it points to one dominant format: a Microsoft SQL Server Compact Edition (SQL CE) database. That is a lightweight, single-file, embedded relational database that runs inside an application with no separate database server. Microsoft introduced it around 2005 as SQL Server Mobile / Compact Edition and shipped its final SQL CE 4.0 release in 2011. The entire database — tables, indexes and data — lives in one .sdf file of up to 4 GB that you can copy like any other file.
Microsoft has since deprecated the technology: extended support for SQL CE 4.0 ended on 13 July 2021, with no successor, and developers are pointed to SQLite or LocalDB instead. Many .sdf files you meet today are therefore legacy data belonging to older .NET desktop applications and Windows Mobile / Windows Phone apps, and the practical question is how to read them without the original, often retired, program. Because the same three letters are reused by unrelated formats, this article first confirms that a given .sdf really is the SQL CE database.
Telling the three .sdf formats apart
Three distinct file types share the .sdf extension, and confusing them wastes time. The simplest discriminator is whether the file is text or binary, which you find by opening a copy in a text editor.
| If the file is ... | It is probably |
|---|---|
| Binary, unreadable in Notepad, from a .NET/Windows app’s data folder | A SQL Server Compact database (this article) |
Readable text with molecule blocks and $$$$ record separators | An MDL/Symyx chemical Structure-Data File |
| From Autodesk FDO / MapGuide, a GPS or survey tool | A spatial or export “spatial data file” |
The chemical Structure-Data File is a plain-text cheminformatics format that stores molecule structures plus tagged data fields, read by tools such as Open Babel, RDKit and ChemDraw. The spatial variant is app-specific export data. Neither is a database, and neither opens in the SQL CE tools below. If your .sdf shows readable chemistry or coordinate text, you are looking at one of those, not the Microsoft database.
Inside a SQL CE database: pages, tables and indexes
A SQL CE .sdf is a binary, page-structured file: the storage engine divides the file into fixed-size pages and organises the data as B-tree structures within them, the same general approach used by most embedded databases. Microsoft did not publish an on-disk magic number or a documented byte layout for the format, which is one reason it is not human-readable and cannot be reliably identified by a signature the way a JPEG or PDF can. What the file contains, logically, is a complete relational database.
- Header and pages: the binary page structure that holds everything else.
- Tables: the relational tables with typed columns — the actual application data.
- Indexes: B-tree indexes that speed up queries.
- Schema metadata: table and column definitions, primary and foreign keys, constraints.
- Optional encryption: SQL CE supports password-protected, encrypted
.sdffiles, so a viewer may prompt for the database password.
Because there is no published spec for the byte layout, the reliable way to read an .sdf is through software that understands the SQL CE engine, not by parsing the file yourself. That is what the tools in the next section do.
Reading a legacy .sdf without the original app
Since SQL CE is retired and modern SQL Server Management Studio dropped support for it, third-party tools are now the practical route. CompactView is a free, read-only viewer that opens an .sdf, lists its tables and runs queries with no SQL CE install — the best first choice for simply reading a legacy database. The SQL Server Compact Toolbox (by ErikEJ) is an open-source tool and Visual Studio add-in that browses, queries, scripts and migrates a database, including a built-in “migrate to SQLite” function. SDF Viewer is a maintained commercial viewer that reads and edits data and exports to CSV, XML or XLS. For a password-protected file you need the application’s database password before any of these can open it.
Getting the data out: CSV, SQLite and other targets
Most people opening a legacy .sdf want to extract or migrate its data rather than keep it in a dead engine. Two paths cover almost every case. To pull individual tables into a spreadsheet, export each table to CSV or XLS from SDF Viewer, the SQL Server Compact Toolbox or CompactView, then open the result in Excel. To move the whole database somewhere current, migrate it to SQLite, which is Microsoft’s own recommended successor: the SQL Server Compact Toolbox has a one-command migration, and general database-copy tools such as Full Convert can copy the schema and data into SQLite, Access (.mdb/.accdb) or a full SQL Server (.mdf) database. There is no meaningful direct .sdf-to-PDF conversion, since a database has no page layout; you would export a table and print that.
Frequently asked questions
How do I open a .sdf file?
If it is a SQL Server Compact database (the common case), use a free tool like CompactView or the SQL Server Compact Toolbox to browse the tables, or SDF Viewer to view and export data. Do not use a text editor: it is a binary database.
Why does my .sdf look like random characters in Notepad?
Because the SQL CE .sdf is a binary database, not text. Open it with a database viewer such as CompactView, SDF Viewer or the SQL Server Compact Toolbox instead.
Is SQL Server Compact still supported?
No. Extended support for SQL CE 4.0 ended on 13 July 2021 and there is no successor. Existing .sdf files still open in third-party tools; Microsoft recommends migrating the data to SQLite or LocalDB.
Is every .sdf file a database?
No. The same extension is used by a plain-text chemical Structure-Data File (molecule data) and by some spatial or export tools. Open it as text first: if it is readable chemistry or coordinate text, it is not the SQL CE database.
References
- Microsoft Learn — SQL Server Compact 4.0 support lifecycle
- ErikEJ — SQL Server Compact Toolbox (open .sdf, migrate to SQLite)
- CompactView — free SQL CE .sdf viewer
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.