SQL dB to SQLite

Source: Internet
Author: User

Http://www.codeproject.com/Articles/26932/Convert-SQL-Server-DB-to-SQLite-DB

 

 

  • Download source (v1.13)-443.25 KB
  • Download source (v1.14)-453 KB
  • Download source (v1.15)-459.15 KB
  • Download source (v1.16)-591.13 KB
  • Download source (v1.17)-583.16 KB
  • Download compiled version of project-564.39 KB


Introduction

I needed to convert the existing SQL Server databases to SQLite databases as part of a DB migration program and did not find any decent free converter to do the job.

This is my attempt to solve the problem. I shoshould warn you though that I did not have much time to test it on too databases. in any case-the source code is very well known ented and easy to understand, so if you do have a problem it shoshould be relatively easy to fix. (Please send me the fixed source code. if you do so, I can update the software so that everybody can enjoy it .)

Using the code

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 listTableschemaObjects 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.

Basically, that's it!

Points of interest

In order to read the SQL Server dB schema, I was mainly using the pseudoInformation_schema.tableTable. You can find more information about it on the Internet if you want.

History
  • 13th June, 2008: initial version
  • 08th July, 2008: v 1.2
    • Fixed a bug that caused unique indexes to be generated as non-unique in some cases
  • 08th July, 2008: V 1.3
    • Fixed a bug that caused the utility to crash sometimes when processing index information
  • 17th July, 2008: V 1.4
    • Fixed a bug that caused wrong columns to become primary keys on rare occasions and improved conversion performance
  • 20 th July, 2008: V 1.5
    • Added support for case-insensitive columns (Collate nocase)
  • 22nd July, 2008: V 1.6
    • Added support for encrypting the resulting dB file (using the built-in encryption support that exists in the SQLite. net provider)
  • 05th October, 2008: V 1.7
    • FixedInformation_schemaReferences to use upper-case in order to resolve international character set issues (Turkish)
  • 14th December 2008: v1.8
    • Integrated support for foreign keys from the revised version made by Yogesh jaota
    • Merged support for selective table Import
  • 21st February 2009: v1.9
    • Added contribution from Johnny Dickson Cano that allows to select using SQL Server integrated security or using user name/password instead
    • Added support for convertingIdentityColumnsAutoincrementIn SQLite (suggestion by Paul Shaffer)
  • 04th March 2009: v1.10
    • Fixed a bug that caused the converter to crash when encountering a datetime field in the original SQL Server schema. ThanksBmcclintFor sending me the bug with the correct bugfix.
  • 23rd May 2009: v1.11
    • Added support for simulating Foreign keys using triggers (contributed by Martijn muurman)
    • Added a small bugfix so that now'Int'Type is always converted'Integer'Type in SQLite. This was needed because SQLite will autoincrement only on'Integer'Column types.
  • 04th June 2009: v1.12
    • Fixed a bug in trigger Generation Code that caused schema generation to fail when more than a single column is referencing the same column in a foreign table
  • 20th September 2009: v1.13
    • FixedAutoincrementBug suggested by MAEP
    • Fixed 64 bit support problem (thanks to Murry gammash)
    • Added support for converting SQL Server views (suggested by Richard Thurgood)
  • 22nd September 2009: v1.14
    • Fixed a critical bug that caused the conversion process to fail on some SQL Server databases that used the [DBO] notation.
  • 25th September 2009: v1.15
    • Fixed a critical bug that caused the primary keys to be discarded
    • Fixed trigger generation bug
  • 4th December 2009: v1.16
    • Fixed generation code to create guid types for SQL-server'sUniqueidentifierType (insteadNvarcharAs it was until now)
    • Updated the solution to use the latest SQLite. net provider Library
  • 24th March, 2011
    • Attached compiled version of the project for anyone that doesn't have Visual Studio and still needs to use the utility
  • 1st, July, 2011
    • Updated binary zip as the earlier one was missing the DLL file needed by the application
  • 15th Nov 2011: v1.17
    • Fixed a bug that caused the software to crash when encounteringNullValues in some of SQL Server meta data tables
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.