Problem to import new data

Shirase 91 Reputation points
2020-10-08T14:49:22.21+00:00

Hi all,

! At first I am sorry if this question doesnt belong here ... I didnt know where to put it ..

Till now I have used a SQLite and from today I start with SQL (SQLServer). First I did is export data from old database to file db_name.db.sql ... Now I am trying to import data in SQL Management Studio. So I mark my database, click on File -> Open -> File ... and ... after file is read ... I tried to execite it ... but there shows an error.

Code from that file begin with ...

BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "table_name" (
    "id"    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
...

and that error is "syntax error at line ..... " Do you know how to export data to correct format.

SQL Server Other
{count} votes

Accepted answer
  1. Guoxiong 8,206 Reputation points
    2020-10-08T19:15:22.65+00:00

    Are you able to export data from SQLite to the excel or text file? If yes, you can import data from the excel or text file to the table in the SQL server database.

    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Tom Phillips 17,771 Reputation points
    2020-10-08T17:28:00.387+00:00

    There are many syntax and functional differences between database engines. You are not going to be able to simply run your scripts from sqlite on SQL Server.

    SQL Server does not support "IF NOT EXISTS" on CREATE TABLE. It also does not support "AUTOINCREMENT".

    I suggest you look at something like this to help you with your conversion:
    https://dbconvert.com/sqlite/mssql/

    1 person found this answer helpful.
    0 comments No comments

  2. Yitzhak Khabinsky 26,586 Reputation points
    2020-10-08T15:11:38.29+00:00

    Unfortunately, MS SQL Server doesn't support 'CREATE TABLE IF NOT EXISTS...'
    You can run find and replace for the 'IF NOT EXISTS' with empty string in your *.sql script file.

    0 comments No comments

  3. Shirase 91 Reputation points
    2020-10-08T18:52:55.597+00:00

    I know it doesnt support a lot of things like ... if not exists or boolean etc. ... but I want to know if ther is something like converter or other way of how to get data from sqlite database to sql server database ...

    0 comments No comments

  4. m 4,276 Reputation points
    2020-10-09T02:52:45.957+00:00

    Hi @Shirase ,

    ...and that error is "syntax error at line ..... "

    Do you use the syntax in English Environment?

    And do you want to import data from SQLite?

    Try this : creating-a-sql-server-linked-server-to-sqlite-to-import-data

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.