cancel
Showing results for 
Search instead for 
Did you mean: 

Can you stop a DEFAULT TIMESTAMP field from updating on an update statement?

3,450

Is there a way of stopping DEFAULT TIMESTAMP columns from updating the timestamp when you perform an UPDATE statement?

We need to run an update statement on a table to fix up some data, however we don't want that update to be reflected by the UpdatedAt default timestamp column.

Accepted Solutions (1)

Accepted Solutions (1)

MCMartin
Participant

You can just include the column with a value in your update statement:

Update table set UpdatedAt ='2012-01-01'

Will change the value to the 1st January...

you can even do something like this:

Update table set UpdatedAt = UpdatedAt, ...

This will leave the value as before

VolkerBarth
Contributor
0 Kudos

Just to add: The method Martin has shown does work that way since a DEFAULT TIMESTAMP is a default (though a particular one), and you can always overwrite a column default value simply by specifying a value for the column...

We use the "set UpdatedAt = UpdatedAt" form regularly to prevent such meaningful timestamps from getting updated when doing "maintenance tasks".

Breck_Carter
Participant

Don't tell the auditors... 🙂

VolkerBarth
Contributor
0 Kudos

Well, the TRANSLOG will tell:)

Answers (0)