简体   繁体   中英

Best way to export SQL Server database to sqlite (or SQL Server Compact)

Do someone know what would be the best way to transform a big SQL Server database to sqlite or SQL Server compact ?

SQL Server database should be around 50-70Gb.

There are some examples on internet (script schema) but I didn't find anything concluding about data.

You can use my Exportsqlce tool to create .sql files in sqlite format from a SQL Server database. Then run them using sqlite3.exe

Download command line tools from https://github.com/ErikEJ/SqlCeToolbox/releases/tag/3.5.2

Export2SQLCE.exe "Data Source=(local);Initial Catalog=Northwind;Integrated Security=True" Northwind.sql sqlite

Good luck!

(I also have SSMS and VS extensions that allow you to do this from a GUI)

I just did this too with SqlCeToolbox, actually through the SSMS (Sql Server Management Studio) gui — Export my SQL db to SQLite db in SSMS · Issue #327 · ErikEJ_SqlCeToolbox · GitHub . But it made over 100 .sql script files I had to pipe to sqlite3.

# powershell
dir *.sql | sort name | % { "$_"; cat $_ | sqlite3 newdatabase.db } 

It worked except for 3 parse errors, but I only lost 3 rows. Somehow directly making the sqlite db failed.

By the way, searching the script file dump is a create way to search every table. Search Sqlite Database - All Tables and Columns

sqlite3 database.db .dump | select-string whatever

INSERT INTO mytable VALUES(0,0,0,'whatever',0);

I'm using this software from Code Project:

Convert SQL Server DB to SQLite DB

It connects with your SQL Server and opens Databases to select and select file destination将 SQL Server 转换为 SQLite

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM