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
 Old Forums
 CLOSED - General SQL Server
 field to show inserting and updating of records

Author  Topic 

abyie
Starting Member

42 Posts

Posted - 2006-09-01 : 10:24:42
Hi,
I neeed to add a column on a few table which would show me
the date and time a new record was inserted or a record was updated on the table.I created a column called LastModified with a datatype timestamp but it showing me binary values.Can I know why and if there is another of doing it then please let me know?

Thanks

----------
Abyie

casati74
Posting Yak Master

109 Posts

Posted - 2006-09-01 : 10:45:29
Hi,
i don't know very well sql but when i create a date column i use the datadate type and getdate() function to insert a date.

I hope is what you want
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-01 : 10:51:25
Timestamp is not useful for audit log, it is just use to version-stamp rows.
Better add a datetieme column along with GetDate() as default attached to it and add an Update trigger which will update this datetime column (LastModified) with current date.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

abyie
Starting Member

42 Posts

Posted - 2006-09-01 : 13:13:15
Thanks Harsh,
It worked perfectly for me...Really u guys r gr8.keep up
the good work.

Cheers
---------
Abyie
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-02 : 10:18:59
Note that timestamp has nothing to do with date. The column gets updated whenever record is inserted or updated

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -