Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger to set time stamp does not fire

Status
Not open for further replies.

RSWolf

Technical User
Apr 19, 2001
1
DE
I need to set a timestamp (actual server system time) on each inserted row.
There is a primary key column named "doc_id"

I try using this trigger:
Create Trigger mytrigger On mytable
For Insert As
Update mytable
Set mystamp = getdate() where doc_id in (select doc_id from inserted)

For some reason, all inserted rows still have a value of "1.1.1900 00:00" in the column "mystamp."

What is wrong with what I am doing???
 

I recommend using a default value for the timestamp column.

Your column must be of data type datetime or smalldatetime and the default value can be set as the function getdate(). getdate() returns the current server datetime.

This works very quickly without the added overhead of executing a trigger.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top