syntax error?

MichaelTJ

Member
Licensed User
Longtime User
Cursor1 = SQL1.ExecQuery("CREATE Table DataTable_backup As Select * FROM DataTable")

the above gives an error if the "DataTable_backup" already exists and no error if the "DataTable_backup" does not exist however, it will not create the "DataTable_backup" nunder any circumstances.....

is my syntax incorrect?
 

barx

Well-Known Member
Licensed User
Longtime User
The SQL statements, looks ok to me. Although I have never used that type of statement, though a CREATE statement should be used with sql.ExecNonQuery()
 
Upvote 0

MichaelTJ

Member
Licensed User
Longtime User
gave it a try but....

it pops back with something about not assigning a void value.... really i just want to do a table backup so a delete followed by a create will do me.... could you please give me the minimalist query for moving all records from one table to a second and completely identical table..... thank you
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
1) Check if the new tables already exists and if so, drop it
B4X:
SQL1.execNonQuery("DROP TABLE IF EXISTS DataTable_Backup")
2) Follow the change proposed by Barx.
B4X:
 SQL1.execNonQuery("CREATE Table DataTable_backup As Select * FROM DataTable")
 
Upvote 0
Top