I try to create MS Access Table with autoincrement ID and Default Date field, but next query always says “Syntax error in CREATE TABLE statement.”:
CREATE TABLE Table1
(
[ID] AUTOINCREMENT,
[Email] TEXT(255),
[ProductID] NUMBER,
[DateCreate] DATETIME,
[DateSend] DATETIME
);
ALTER TABLE Table1
ALTER [DateSend] DATETIME DEFAULT NOW() NOT NULL;
Who can help me to fix that query. Thanks!
There are many
NUMBERtypes in Ms-Access, so you have to be specific. I guess you wantInteger.The
ALTER TABLEsyntax requiresALTER COLUMN:You could also have those two in one statement:
It’s best practise to have a
PRIMARY KEYon every table, and you probably intended that for theID:A page with a lot of useful information about how to handle Access with SQL:
Intermediate Microsoft Jet SQL for Access 2000