BobMcGee
BobMcGee

Reputation: 20110

Why is this very simple SQL query failing in MS Access?

I have a query that by all rights should not possibly fail, and I can't for the life of me figure out why

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,Note) 
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what is going on");

When I try to run the query I get "Syntax error in INSERT INTO statement" with the Note field highlighted. If I omit the Note field and its value, the query works fine. Is there something really obvious I'm missing, or is there an Jet SQL quirk buried here???

The table it's acting on is: Grocery_Store_Prices

Upvotes: 5

Views: 1393

Answers (2)

Michael Ames
Michael Ames

Reputation: 2617

"Note" is a reserved word in Microsoft Access. You need to surround it with square brackets:

INSERT INTO Grocery_Store_Prices(Store,Item,Brand,Price,Unit,Quantity,[Note])
VALUES("Kroger","Cheesy Poof","Cartman",0.51,"fart",15,"what the ____");

Helpful list of reserved words here: http://support.microsoft.com/kb/286335

Some consider it best practice to always encase field names in square brackets, just so you don't have to worry about it.

Good luck!

Upvotes: 9

paulmorriss
paulmorriss

Reputation: 2615

Note is a reserved word, so try renaming that column.

Upvotes: 4

Related Questions