creating trigger

Last Post 03 Dec 2006 02:26 AM by SQLUSA. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
TRACEYSQL
New Member
New Member

--
27 Nov 2006 09:37 AM
First time writing a trigger


This needs to update reason code when new record inserted and
updated records.

Is this correct for both cases.

Getting confused on UPDATE x
as i usually do UPDATE (TABLENAME) here or
UPDATE DELTEK.EMPL_LAB_INFO X if doing in query analyzer

Do i need to change below ?

CREATE TRIGGER TR_Empl_Lab_Info
ON DELTEK.EMPL_LAB_INFO
AFTER UPDATE, INSERT
AS
UPDATE x
SET PERS_ACT_RSN_CD = 'NCT'
FROM DELTEK.EMPL_LAB_INFO X
INNER JOIN INSERTED on x.EMPL_ID = inserted.EMPL_ID and
x.EFFECT_DT = inserted.EFFECT_DT
WHERE x.REASON_DESC = 'NEW HIRE CONTRACT TRANSITION'


Topic
SQLUSA
New Member
New Member

--
03 Dec 2006 02:26 AM
The trigger is correct.

The UPDATE does have confusing syntax. See article: http://www.sqlusa.com/articles2005/...atesyntax/


Kalman Toth DB, DW & BI Architect, SQL Server Training
URL: http://www.sqlusa.com/order2005grandprix
The Best SQL Server 2005 Training in the World
You are not authorized to post a reply.

Acceptable Use Policy