CREATE TABLE Query, DEFAULT value DateTime

G

GaryN

I am putting together some scripts to run in VB to create an ACCESS database
and it's schema.

As a part of each table I want to have a timestamp field that on record
insertion defaults to the current datetime stamp.

What would the CREATE TABLE statement look like for this, assuming that it
can be done.

Thanks,

Gary Novosel
 
R

RoyVidar

GaryN said:
I am putting together some scripts to run in VB to create an ACCESS
database and it's schema.

As a part of each table I want to have a timestamp field that on
record insertion defaults to the current datetime stamp.

What would the CREATE TABLE statement look like for this, assuming
that it can be done.

Thanks,

Gary Novosel

You could try something like this

CREATE TABLE myTest
(id Counter PRIMARY KEY,
myDesc Varchar (25) NOT NULL,
myDate DATETIME DEFAULT Now())
 
G

GaryN

For further clarification assume the following base CREATE query:

CREATE TABLE LogTable
(ID INTEGER PRIMARY KEY
,TimeStamp DATETIME DEFAULT ????????
)
 
G

GaryN

That's it!

Thanks, Gary
--

Gary Novosel



RoyVidar said:
You could try something like this

CREATE TABLE myTest
(id Counter PRIMARY KEY,
myDesc Varchar (25) NOT NULL,
myDate DATETIME DEFAULT Now())
 
R

RockClimber

I'm using .ASP script to create a table in an MS Access database (ODBC).
I've tried:
MyTime DATETIME DEFAULT Now()
DEFAULT Now
DEFAULT (Now)
DEFAULT (Now())
And they all give me a syntax error. I've temporarily left out the DEFAULT
just so that I can develop the rest of the web project, but I really need to
have the current timestamp as the default value for MyTime column. Anybody
know what's wrong?
 
Top