Connecting Tech Pros Worldwide Help | Site Map

Computerised Date

Newbie
 
Join Date: Jul 2008
Posts: 2
#1: Jul 30 '08
Hi,

Is it possible to have a date stamp auto created in a SQL table on Insert? I have a 3rd party software that can update a 3rd party database (i.e. my sql database), but it has no option to add the current date/time when inserting a new row into the table, hence I'd like sql to automatically populate the date/time in the column when the row is created.

I've tried using GETDATE() in 'Computer Column Specification', but when the column is set to 'Is Persisted' the table can't be saved due to the error ' the column is non-deterministic' - this is apparently by design.

Is there any other options to auto generate a datetime in a column on insert of a row?

Thanks
Oli
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 30 '08

re: Computerised Date


Alter your table and add a new column, say DLUP (Date of Last Update). Set the default value to GETDATE()

-- CK
Newbie
 
Join Date: Jul 2008
Posts: 2
#3: Jul 31 '08

re: Computerised Date


Can't believe I missed that!... Great, did the job.

Thanks
Reply


Similar Microsoft SQL Server bytes