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 2008 Forums
 Transact-SQL (2008)
 Automatically updating a Datetime column

Author  Topic 

santkris4
Starting Member

10 Posts

Posted - 2011-02-25 : 15:37:06
I was reading through a lot of forums regarding this requirement.
I have a SQL 2008 R2 box and i have a ChangeDatetime column which is of type Datetime. I was thinking of updating this column with the systemdatetime value everytime a row gets updated (Not inserted!).

Other than doing this using a trigger or passing as a value from the consuming app, are there any new features as part of 2008 or 2008 R2?

I looked at TIMESTAMP datatype but that doesnt address the requirement.

All comments are greatly appreciated!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-25 : 15:39:06
Trigger or via the actual update statement are your options. Why are you looking for another way?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

santkris4
Starting Member

10 Posts

Posted - 2011-02-25 : 15:56:20
Thanks.
I did not want the consuming app to send it as another value if SQL can automatically update this since it is just updating a datetime value. I shall probably go with the consuming app passing this value instead of triggers.

quote:
Originally posted by tkizer

Trigger or via the actual update statement are your options. Why are you looking for another way?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2011-02-25 : 18:30:11
No, you don't have to pass the current dateTime value as long as it is (sql) server time you want to record.

Just set the column value to getDate() or sysDateTime or ...

Take a look here [url]http://msdn.microsoft.com/en-us/library/ms186724.aspx[/url]

Mirko

My blog: http://mirko-marovic-eng.blogspot.com/
Go to Top of Page
   

- Advertisement -