Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pha2er
Starting Member
6 Posts |
Posted - 2002-05-16 : 17:08:00
|
| Hi there,just wondering if there was a way I could set up a column to automatically insert the current date and time, in much the same way as you set up the identity seed.Thanks! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-05-16 : 17:38:01
|
| Yes, here's an example:CREATE TABLE myTable ( col1 int, myDate datetime DEFAULT(getdate()) )You can INSERT into the table without indicating the myDate column:INSERT INTO myTable (col1) VALUES (1)Or use the keyword DEFAULT:INSERT INTO myTable (col1, myDate) VALUES (1, DEFAULT) |
 |
|
|
pha2er
Starting Member
6 Posts |
Posted - 2002-05-16 : 17:45:38
|
| nice one, thanks! |
 |
|
|
|
|
|