13

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.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Ronan Lamour
  • 1,418
  • 2
  • 10
  • 15
  • 1
    You seriously want to store that kind of data into a single file and a single-user, file-based database system?? – marc_s Sep 26 '14 at 10:53
  • 1
    Max db size on SQL Compact is 4 GB.. And 50 GB with SQLite is simply not feasible – ErikEJ Sep 26 '14 at 10:56
  • It's going to be hard. Max size for a sql compact db is 4gb. http://stackoverflow.com/questions/7524197/does-sql-server-compact-still-limit-to-4gb – John Babb Sep 26 '14 at 10:57
  • My problem is : I must send an offline app who read a database this size. Atm, I use vmware portable with windows+sql server embedded on an external drive. I would like to remove vmware (because of windows+SQL), so I thought about sqlite/sql compact. If you have any other idea... – Ronan Lamour Sep 26 '14 at 11:43
  • According to this message [here](http://stackoverflow.com/questions/54998/how-scalable-is-sqlite#comment230095_66724), reading on a 50GB sqlite file is not a problem and that's exactly what I would like to do. – Ronan Lamour Sep 26 '14 at 11:48
  • But the stated problem is 50-70GB - not exactly 50GB. – paparazzo Sep 26 '14 at 12:35

3 Answers3

29

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)

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
3

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 Convert SQL Server To SQLite

1

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);
js2010
  • 23,033
  • 6
  • 64
  • 66