RE: Need Help With A Trigger

RE: Need Help With A Trigger

 

  


A good suggestion with the Begin..End but this did not solve it.
I have used variations on this If statement in triggers before with success.
Is there another method that would work for this case?

-----Original Message-----
From: Beal, Jeremy [mailto:[Email Address Removed] Tuesday, November 25, 2003 11:15 AM
To: Justin Gilli; LazyDBA.com Discussion
Subject: RE: Need Help With A Trigger

Create trigger[WhseInsert} on dbo.Costing
For insert
AS
If(select WhseCode from inserted)='QON'
begin
Update[Costing]
Set WhseCode = 'ZZZ'
Where ItemNumber in (select ItemNumber from inserted)
End

Should it have a begin-end for this if statement?
I don't think this solves the problem due to my not knowing if the IF
statement itself actually works

Jeremyb

-----Original Message-----
From: Justin Gilli [mailto:[Email Address Removed] Tuesday, November 25, 2003 8:05 AM
To: LazyDBA.com Discussion
Subject: Need Help With A Trigger


I am attempting a trigger on a table. Data for this table is being
imported from another db. I want the trigger to replace the imported
warehouse code with a different code.

I have this so far but it is not working:

Create trigger[WhseInsert} on dbo.Costing
For insert
AS
If(select WhseCode from inserted)='QON'
Update[Costing]
Set WhseCode = 'ZZZ'
Where ItemNumber in (select ItemNumber from inserted)

Syntax checks out but nothing happens.

Advice much appreciated.

Regards,

Justin




---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Get
today's cartoon: http://www.LazyDBA.com To unsubscribe, e-mail:
mssqldba-[Email Address Removed] For additional commands, e-mail:
mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page