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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Trigger Help

Author  Topic 

thegurutobe
Starting Member

2 Posts

Posted - 2007-08-20 : 08:24:01

Hi,

I am using the following trigger but it seems to do the second update and not the first update.


CREATE TRIGGER [PREPSTATUSCOMPLETE] ON [dbo].[PrepLog]
FOR UPDATE
AS
IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME = '---')
UPDATE RMJOB
SET PSTATUS = 'PREPPING' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHTIME = '---'
AND RMJOB.RMJOBID = PREPLOG.RMJOBID
IF EXISTS(SELECT FINISHTIME FROM PREPLOG WHERE FINISHTIME != '---')
UPDATE RMJOB
SET PSTATUS = 'PREPPING COMPLETE' FROM RMJOB,PREPLOG WHERE PREPLOG.FINISHTIME != '---'
AND RMJOB.RMJOBID = PREPLOG.RMJOBID


The first update does not get triggered but the second update gets triggered as soon as the if condition is meant.

Can somebody please help me on this?

A.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-20 : 22:06:52
That means first condition check failed. Did you double check values in source table?
Go to Top of Page

thegurutobe
Starting Member

2 Posts

Posted - 2007-08-21 : 10:33:58
Yes the values in the source table are ok
Go to Top of Page
   

- Advertisement -