Database Triggers

I want to save the insertion time of an insert operation in to an sql server database. How to do it by using trigger?


See All Responses Below...
Author
Message Rating
Posted on: 15/06/2012
I got the answer...

.................................................................................................................................... ..
CREATE TRIGGER [dbo].[tgr_Insert_Time]
ON [dbo].[PacketDataTB]
AFTER INSERT
AS
UPDATE PacketDataTB
    SET InsertTime = GETDATE()
    WHERE idPacketData IN (SELECT DISTINCT idPacketData FROM Inserted)
.......................................................................................................................................

tgr_Insert_Time : the name of the trigger
PacketDataTB :  name of the table
InsertTime : name of the filed
idPacketData : another field

Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Comments
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site. 

 
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android