Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Semicolon at the end of sql statement Access

I am trying to execute the following code. However, I continue to recieve the following 'Missing semicolon (;) at the end of SQL statement error in Microsoft Access.

The first query creates the table with the columns defined.

create table test 
(
    ProcessID int, 
    Name varchar(10),  
    Address varchar(10),    
    RandomData varchar(10)
);

The second query is causing the missing semicolon error.

INSERT into test 
VALUES (123 , 'TestName', 'TestAdd', 'qwrj3ri'), 
       (456 , 'TestName2', 'TestAdd', 'qwerty'),    
       (789 , 'TestName', 'TestAdd', 'qwrj3ri'),    
       (1234, 'Testing123', 'tester', 'asdfghjk');   
like image 985
syavatkar Avatar asked Dec 20 '22 01:12

syavatkar


2 Answers

Code with amendments per above comments to make it Access friendly & remove typos:

INSERT INTO test ( ProcessID, Name, Address, RandomData)
VALUES (123 , 'TestName', 'TestAdd', 'qwrj3ri');

INSERT INTO test ( ProcessID, Name, Address, RandomData)
VALUES (456 , 'TestName2', 'TestAdd', 'qwerty');    

INSERT INTO test ( ProcessID, Name, Address, RandomData)
VALUES (789 , 'TestName', 'TestAdd', 'qwrj3ri'); 

INSERT INTO test ( ProcessID, Name, Address, RandomData)
VALUES (1234, 'Testing123', 'tester', 'asdfghjk');   

Useful reference: https://msdn.microsoft.com/en-us/library/bb243852(v=office.12).aspx

Specific comments:

@Damien_The_Unbeliever:

I don't think access supports multiple rows in the values.

Amended to include an insert into per row instead of a value set per row (values (...), (...)).

@Thomas Tschernich:

our missing single quote next to the end of your insert

Changed 'tester', sdfg') to 'tester', 'sdfg');

@JohnLBevan:

superfluous character on end of first set of values

Changed 'qwrj3ri'), T to 'qwrj3ri'),

like image 165
JohnLBevan Avatar answered Dec 21 '22 13:12

JohnLBevan


You can insert multiple rows in one insert statement in SQL server,but in MS ACCESS its not possible as above listed.

More techniques on multiple inserts in access are described beautifully here

like image 43
Tharif Avatar answered Dec 21 '22 13:12

Tharif