James Kevin De Jesus
James Kevin De Jesus

Reputation: 73

SQL INSERT INTO Error

I'm inserting a record with this SQL command

INSERT INTO Deployment (DateTime, Type, Brand, Model, SerialNo, Assignment) VALUES ('May 20, 2013','LAPTOP','ASUS','K55V','ABCD1234','10F HRD');

But an error popped up saying

Syntax Error in INSERT INTO statement

DateTime is a text type. What should I do?

Upvotes: 2

Views: 227

Answers (2)

HansUp
HansUp

Reputation: 97101

Both DateTime and Type are problem names. Enclose both in square brackets in your INSERT statement.

INSERT INTO Deployment ([DateTime], [Type], Brand, Model, SerialNo, Assignment)
VALUES ('May 20, 2013','LAPTOP','ASUS','K55V','ABCD1234','10F HRD');

Download Allen Browne's free Database Issue Checker Utility and use it to examine your Access db files. In addition to problem object names, it can alert you to other troublesome issues with your databases.

Upvotes: 1

Ben Reich
Ben Reich

Reputation: 16324

I think this error might occur if you try to use reserved words in the query (as stated here). Try wrapping the DateTime column in brackets:

INSERT INTO Deployment ([DateTime], Type, Brand, Model, SerialNo, Assignment) VALUES ('May 20, 2013','LAPTOP','ASUS','K55V','ABCD1234','10F HRD');

Probably a better solution is to change that column name.

Upvotes: 4

Related Questions