Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003

    Lightbulb Unanswered: Help needed with trigger

    Hi All,

    I have this trigger wich runs good!

    CREATE trigger trUpdateGEOData
    on dbo.BK_Machine
    after insert, update
    update	BK_Machine
    set	BK_Machine.LOC_Street = GEO_Postcode.STraatID,
    	BK_Machine.Loc_City = GEO_Postcode.PlaatsID
    from	BK_Machine
    	inner join GEO_Postcode on BK_Machine.loc_postalcode = GEO_Postcode.postcode
    		and BK_Machine.LOC_Doornumber >= GEO_Postcode.van
    		and BK_Machine.LOC_Doornumber <= GEO_Postcode.tem
    	inner join inserted on BK_Machine.MachineID = Inserted.MachineID
    Now the thing is that a machine not neccesarily needs a location which mean that if postalcode or doornumber is NULL this trigger should clear the street and city columns.

    Does someone have an Idea?

    Cheers Wim

  2. #2
    Join Date
    Dec 2004
    California, USA
    LOC_Street = case when insrted.PostalCode is Null or
    inserted.DoorNumber is Null then '' else GEO_Postcode.STraatID end

    Change your UPDATE Statment to include this. Do something similar with Loc_City.
    Whoever imagines himself a favorite with God holds others in contempt. - Robert Green Ingersoll, lawyer and orator (1833-1899)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts