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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 auto date column ?

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-08 : 14:37:33
I have this insert record statment, and I would like a datastamp to be filled in my "createddate" column, can I create a column that will auto do this whenever a new record gets inserted, or should I handle it in the stored procedure

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-08 : 14:41:02
Are you talking about a timestamp column or having a datetime column defaulted to today's date? Read up books online for timestamp columns if you are not sure.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-08 : 14:44:58
I end up doing this in my column

DEFAULT (getdate()),
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-09 : 00:46:45
quote:
Originally posted by johnstern

I end up doing this in my column

DEFAULT (getdate()),

Yes. Thats it.
Also when adding data to table, you need not to supply value for that column

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -