How to use a SQLServer script to create a database in SQLite?

1

I have a SQL Server generated script it contains several tables and views, I intend to carry this database to my Android SQLite.

How do I run the script in SQLite on Android?

    
asked by anonymous 16.02.2017 / 21:39

1 answer

2

Follow the steps below:

  • On the side of SQLServer manages the creation script.

  • Change the script to be compatible with SQLite.

  • Derive from SQLiteOpenHelper and use the script in the same way it does when you create any other database, using db.execSQL() .

Note: db.execSQL() only executes one SQL statement at a time. You'll get each of the existing SQL commands in the script and run them one by one, something like this:

StringTokenizer tokenizer = new StringTokenizer( script, ";", false);

while (tokenizer.hasMoreTokens())
{
    db.execSQL(tokenizer.nextToken());
}
    
17.02.2017 / 12:37