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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, just 2 only yesterday I start u 1

Status
Not open for further replies.

Adhie

Programmer
Mar 17, 2003
28
0
0
SG
Hi, just 2 only yesterday I start using Trigger.
I have 2 tables:
tblAmendment
------------
PageId
actiontime

tblTest
----
pageId
tester

I want if any update on tblTest then we record down which record updated on tblAmendment and action time. So I create this trigger on tblTest.

CREATE TRIGGER trgAmendment ON dbo.tblTest
FOR UPDATE AS
BEGIN
INSERT INTO dbo.tblAmendment
(pageId, actiontime)
VALUES (???????, CurrentTime())
END

How to pass pageId value from tblTest to tblAmendment?

Thank you very much, have a nice day.....
Martin
 
You can use the inserted pseudo-table to get details of the updated rows:

Code:
CREATE TRIGGER trgAmendment
  ON dbo.tblTest
  FOR UPDATE
AS

SET NOCOUNT ON

INSERT tblAmendment (pageid, actiontime)
SELECT pageid, getdate()
FROM inserted
GO

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top