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
 General SQL Server Forums
 New to SQL Server Programming
 Automatically record datetime to a field

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-01-14 : 05:29:06

Hallo,

I have created a table in sql server 2005, called tblpracdetailshistory. This table has a field called record_crt_time field. The datatype is set to datetime.

Now, What I want to do is whenever a new record is created this field (record_crt_time) records the system time.

Is it possible?

Thanks

Sachin.Nand

2937 Posts

Posted - 2010-01-14 : 06:02:37
Yes put the default value as getdate()

PBUH
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-14 : 09:52:57
[code]
alter table tblpracdetailshistory add constraint df_tblpracdetailshistory_record_crt_time default getdate() for record_crt_time
[/code]
will create the default on new records
Go to Top of Page
   

- Advertisement -