how can i insert a default value for a datetime field, with something like the VB '=Now()' ?
thxINSERT table(column) VALUES(GETDATE())
INSERT table(column) VALUES(CURRENT_TIMESTAMP)
You could also set the column to have a default value, and leave it out of
your insert statement, e.g.
CREATE TABLE blat
(
foo INT NOT NULL PRIMARY KEY,
splunge DATETIME NOT NULL
DEFAULT GETDATE()
)
GO
INSERT blat(foo) VALUES(1)
WAITFOR DELAY '00:00:02'
INSERT blat(foo) VALUES(2)
SELECT foo, splunge FROM blat
GO
DROP TABLE blat
GO
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Phalle" <anonymous@.discussions.microsoft.com> wrote in message
news:340BC29F-9362-448D-B0A8-ED80BF8C67F1@.microsoft.com...
> how can i insert a default value for a datetime field, with something like
the VB '=Now()' ?
> thx
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment