How to generate script from .sdf database?

Updated on     Kisan Patel


How to generate script from sdf database?
How to Convert .sdf database to .mdf database?
How to migrate from SQL Compact Edition (sdf file) to SQL Server database?


To generate script from .sdf (Compact Database), first you need to install SQL Server Compact & SQLite Toolbox extension in visual studio.

To install “SQL Server Compact & SQLite Toolbox” extension go to TOOLS => Extensions and Updates => click “Online” Tab from right side menu => Search “SQL Server Compact & SQLite Toolbox” in search box => click “Download” and Install.


Next, Open Server Explorer in Visual studio (In visual studio go to VIEW => Server Explorer) and click on “SQL Server Compact & SQLite Toolbox” icon as shown in below screenshot.


Next right click on “Data Connections” tab and Add SQL Server Compact 4.0 Connection… as shown in below screenshot then click on Browse to connect your existing .sdf databse then click OK.


Now, right click database => Script Database => Script Database Schema and Data as shown in below screenshot and save it as .sql.



SQL Server Visual Studio

Leave a Reply