Local StudioDATABASE TOOLS

MDF to SQL Script

Convert MDF to SQL for just the tables you choose. Open a SQL Server MDF and its required NDF files, then download a UTF-8 script to replay in a separate database.

  • Free
  • Works Offline
  • No Uploads
Works with:
  • Microsoft Edge
  • Google Chrome
  • Mozilla Firefox
  • Safari
MDF to SQL Script with the sample database open, Core.Orders selected, and Core.Customers and the unsupported Documents table excluded.
The sample file set is open and only Core.Orders is selected for export.

How to Convert MDF to SQL

  1. Open the HTML, review Security Check, then select Continue.
  2. Select Open Sample or choose one MDF and any required NDF files. Add missing companion files with Add NDF Files.
  3. Select the tables you want. Choose Preview to inspect a table’s column definitions and up to 100 stored rows.
  4. Select Generate SQL Script, then Download. Use Save As where your browser makes it available.
  5. Run the UTF-8 script as one batch in an empty SQL Server 2025 user database with compatible collation and SQLCMD mode off. Compare the resulting tables and row counts.

MDF to SQL Script Features

  • Review each table’s column and row counts before choosing what to share.
  • Preview column types and sample rows. Unsupported definitions block export until you clear the affected selection.
  • Save selected table definitions and rows as Transact-SQL, with SQL NULL, quoted strings, and exact supported numeric values.

Formats and Compatibility

InputA readable primary SQL Server .mdf and every required .ndf from the same cleanly detached snapshot. The format reader requires complete data files totaling up to 2 GB.
OutputOne UTF-8 .sql script for Microsoft SQL Server (Transact-SQL), with schema names, CREATE TABLE statements, nullability, and literal INSERT values for the selected tables.
BrowserA modern browser with local file support.
ScopeVerified with cleanly detached SQL Server 2025 MDF and NDF files. The reader requires complete data files totaling up to 2 GB and may reject layouts or values it cannot verify. The script carries base column definitions and rows as decoded. SQL Server features such as indexes, constraints, identities, original collations, filegroups, triggers, permissions, and stored code are omitted.
Operating Systems
  • Windows
  • macOS
  • Linux
  • ChromeOS

Local Processing Without Uploads

Use MDF to SQL without uploading files. Processing runs in the browser with no upload, and the original database files stay on your device.

Select The sample includes an MDF and an NDF created by SQL Server 2025. Replay of the Core.Orders export preserved the text reference 00073, the multiline Unicode note, a NULL note, and bigint 9007199254740993. Core.Customers was excluded. to see the workflow with the included example.

From Database Pages to SQL Statements

An MDF stores SQL Server pages, and an NDF holds secondary data pages where the database uses multiple files. This tool can extract CREATE TABLE and INSERT statements from MDF and its companion files for readable tables with supported scalar types.

Replay the Script in SQL Server

Open the UTF-8 file in a SQL Server 2025 query window with SQLCMD mode off, select an empty user database with compatible collation, and run the complete script as one batch. Check the tables and record counts. Very large scripts can exceed the query client's batch or memory limits.

Frequently Asked Questions

How do I use MDF to SQL offline?

Extract the tool ZIP and open MDFToSQLScript.html. Choose your local database files or Open Sample. The standalone converter works without an internet connection.

Where is the MDF to SQL download?

Select Download Tool ZIP to keep the tool. After generating your own script, select Download in the result to save its .sql file.

What does a local MDF to SQL conversion include?

The script includes the selected schemas and tables, supported column types and nullability, and their stored row values. It omits identity behavior, keys, indexes, defaults, collations, filegroups, permissions, triggers, and stored code.

Is this a free MDF to SQL tool?

Yes. The standalone tool is available free for personal and business use under the Local Studio Free Software License.

How does MDF to SQL in browser mode read my files?

Open the local files with the browser’s file picker or drop them on Source Database. The converter uses the included file reader without a server or upload.

Which column types can I export?

Supported mappings include integer and bit, decimal and numeric, money, float and real, Unicode and ASCII-only character values, binary values, uniqueidentifier, date, time, datetime2, and datetimeoffset. XML, spatial types, aliases, legacy large-object types and rowversion are outside this export. A table that cannot be read exactly cannot generate a result.

What happens if an NDF is missing?

The source panel identifies the missing companion. Add the matching NDF from the same snapshot before you export. The reader also checks supplied NDFs against the MDF.

Does this tool work offline on Windows, macOS, Linux, and ChromeOS?

Yes. Local Studio tools run offline on Windows, macOS, Linux, and ChromeOS. Download the tool ZIP, extract it, and open the included HTML file in a supported browser. Your files are processed on your device without uploads.

Which browsers can I use with this offline tool?

Use a current version of Google Chrome, Microsoft Edge, Mozilla Firefox, or Safari where that browser is available for your operating system. Chrome is built into ChromeOS, and Safari is available on macOS.