0

I'm just starting out experimenting with SQL on MS Access. I'm trying to insert data into a table, and I can't figure out what I'm doing wrong here. I know it's probably something simple so I apologize in advance. Thanks for any help you can give me!

Here's what I've got:

CREATE TABLE DeathDay
  (
     ID        INT PRIMARY KEY NOT NULL,
     LastName  CHAR(25),
     FirstName CHAR(10),
     DoB       DATE,
     DoD       DATE
  );

INSERT INTO DeathDay
VALUES      (1,
             'Breitenbach',
             'Max',
             '1991-05-17',
             '2022-12-31'); 

I can create the table fine, but it gives me the following error message when I try to insert the data.

"Syntax error in CREATE TABLE statement"

9
  • 1
    Are you guessing when someone will die for DoD? Perhaps that's why you're receiving an error. Commented Jan 28, 2013 at 21:23
  • This question is rather grim.. Commented Jan 28, 2013 at 21:24
  • 1
    The delimiter for literal values inserted into date fields is #. Try using #1991-05-17# and #2002-12-31# instead. Commented Jan 28, 2013 at 21:24
  • I just tested both in MS Access 2010 and received no error. What is the error? Commented Jan 28, 2013 at 21:25
  • 1
    Might be a dupe of this question Commented Jan 28, 2013 at 21:27

2 Answers 2

3

I just ran your scripts in separate query windows in MS Access 2010 and there was no error. However, if you try running them at the same time, you get an error:

Syntax error in CREATE TABLE statement

Based on my experience you cannot run multiple queries in the same query window.

If you want to run multiple queries then you want to use a script to process it.

Sign up to request clarification or add additional context in comments.

3 Comments

That was it, thanks! Thought it might be something obvious like that. Just opened a new query window and it worked. Can I delete old query windows after I've run the commands? It seems like it would get rather cluttered if I keep all the old queries.
Yes, you don't need to keep it unless you have reason to.
In my experience you can't even add multiple records at the same time, let alone queries. ...anything to keep the workday at 40hrs I guess.
0

In case anyone else comes to this question with the same problem as me, I found the issue to be keywords in my SQL statement. In my case "Currency". A list of reserved keywords is available here: http://allenbrowne.com/AppIssueBadWord.html the ones that are relevant to SQL are the Jet keywords.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.