Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting from SQLite to SQL Server

Is there a tool to migrate an SQLite database to SQL Server (both the structure and data)?

like image 480
Geoff Appleford Avatar asked Oct 02 '08 15:10

Geoff Appleford


People also ask

Can SQLite connect to SQL Server?

SQLite is an entirely different database, see http://www.sqlite.org/; the sqlite3 module has nothing to do with Microsoft SQL Server, but everything with the embedded database instead. In other words, you cannot connect to SQL Server using the sqlite3 module. You'll need to install a 3rd-party library to connect.

How do I export a SQLite Studio database?

Right-click on the database, and select "Export the database".


2 Answers

SQLite does have a .dump option to run at the command line. Though I prefer to use the SQLite Database Browser application for managing SQLite databases. You can export the structure and contents to a .sql file that can be read by just about anything. File > Export > Database to SQL file.

like image 87
swilliams Avatar answered Oct 17 '22 18:10

swilliams


I know that this is old thread, but I think that this solution should be also here.

  • Install ODBC driver for SQLite
  • Run odbcad32 for x64 or C:\Windows\SysWOW64\odbcad32.exe for x86
  • Create SYSTEM DSN, where you select SQLite3 ODBC Driver
  • Then you fill up form where Database Name is filepath to sqlite database

Then in SQL Server run under sysadmin

USE [master] GO EXEC sp_addlinkedserver     @server     = 'OldSQLite', -- connection name    @srvproduct = '',          -- Can be blank but not NULL    @provider   = 'MSDASQL',     @datasrc    = 'SQLiteDNSName' -- name of the system DSN connection  GO 

Then you can run your queries as normal user e.g.

SELECT * INTO SQLServerDATA FROM openquery(SQLiteDNSName, 'select * from SQLiteData') 

or you can use something like this for larger tables.

like image 21
Krivers Avatar answered Oct 17 '22 19:10

Krivers