Search code examples
sqlms-accesssyntax

SQL syntax error in create table statement


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"


Solution

  • 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.