Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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.

asked 07 Mar '12, 17:53

Nick%20Brooks's gravatar image

Nick Brooks
668212537
accept rate: 33%


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

permanent link

answered 08 Mar '12, 02:59

Martin's gravatar image

Martin
9.0k130169257
accept rate: 14%

edited 08 Mar '12, 03:01

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".

(08 Mar '12, 03:45) Volker Barth
Replies hidden
2

Don't tell the auditors... :)

(08 Mar '12, 08:30) Breck Carter

Well, the TRANSLOG will tell:)

(08 Mar '12, 08:51) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×143
×7

question asked: 07 Mar '12, 17:53

question was seen: 3,026 times

last updated: 08 Mar '12, 08:51