SQL Server DataBase Convert to SQLite DataBase
July 6, 2008 Sql Server — Tags: SQL, Sql Server, sql server2005, sqllite, sqlserver2000 — 52coding
Ineeded to convert existing SQL Server databases to SQLite databases as part of DB migration program and did not find any decent free converter to do the job. my attempt to solve the problem. I should warn you though that I did not have much time to test it on too many databases. In any case - the source code is very well documented and easy to understand .
The code is split between a DataAccess project (class library) that contains the conversion code itself and a Converter project (winforms) that drives the conversion code and provides a simple UI for user interaction.
The main class that performs the conversion is the SqlServerToSQLite class. It does the conversion by doing the following steps:
1.Reading the designated SQL Server schema and preparing a list of TableSchema objects that contain the schema for each and every SQL Server table (and associated structures like indexes).
2.Preparing an empty SQLite database file with the schema that was read from SQL Server. In this step the code may alter few SQL-Server types that are not supported directly in SQLite.
3.Copying rows for each table from the SQL Server database to the SQLite database.
