Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:36:04+00:00 2026-06-08T18:36:04+00:00

I have the following trigger First trigger: ALTER TRIGGER [dbo].[DIENSTLEISTUNG_Update] ON [dbo].[DIENSTLEISTUNG] INSTEAD OF

  • 0

I have the following trigger

First trigger:

ALTER TRIGGER [dbo].[DIENSTLEISTUNG_Update]
ON [dbo].[DIENSTLEISTUNG]
INSTEAD OF UPDATE
AS

BEGIN
    SET  NOCOUNT ON;
    DECLARE @intNewID int

         INSERT INTO [DIENSTLEISTUNG] 
         (DESCRIPTION, QUANTITY, 
         PRICE, AZ_MO, AZ_DI,AZ_MI,AZ_DO,AZ_FR,
         AZ_SA,AZ_SO,DIENSTLEISTUNGSART_ID,
         UPDATE_USER, UPDATE_DATE,
         PERMISSIONS, KONTRAKTPOSITION,ITEMNUMBER,
         PRIORITY, VALID)

         SELECT  i.DESCRIPTION, i.QUANTITY, i.PRICE, i.AZ_MO, 
         i.AZ_DI,i.AZ_MI,i.AZ_DO,i.AZ_FR,       
         i.AZ_SA,i.AZ_SO,i.SERVICETYPE_ID, i.UPDATE_USER,GETDATE(),
         i.PERMISSIONS, i.KONTRAKTPOSITION,i.ITEMNUMBER, i.PRIORITY, 'Y'

         FROM INSERTED i
         JOIN deleted d ON i.ID=d.ID
         WHERE i.PRICE<>d.PRICE
         or i.DESCRIPTION<>d.DESCRIPTION


         IF ( UPDATE (PRICE) OR UPDATE (DESCRIPTION) )
         UPDATE  S
         SET  s.VALID = 'N'    
         FROM SERVICE s
         JOIN INSERTED i ON I.ID = S.ID


         IF UPDATE(PRIORITY)
         UPDATE s
         SET s.PRIORITY= i.PRIORITY
         FROM SERVICE s
         JOIN INSERTED i ON i.ID = s.ID

   SET NOCOUNT OFF;      
END

The first Trigger copies an entire row with a new ID if a change in the original row happens, also the trigger set a flag. The old row gets the flag VALID = 'N' and the new row gets the flag VALID = 'Y'. The trigger only creates a new row if PRICE or DESCRIPTION are updated. So far so good.

My problem is that if I want to update the PRIORITY in the new row the trigger fires again and sets the flag to VALID = 'N'. That should not happen. I want only to update the priority without creating a new row or update a another column.

Thanks for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:36:07+00:00Added an answer on June 8, 2026 at 6:36 pm

    You cannot prevent a trigger from firing – if it’s present and not disabled, it will fire. That’s how triggers work.

    What you can do is check inside your trigger which columns have been updated. So you could do something like this in your one single trigger:

    CREATE TRIGGER [dbo].[DIENSTLEISTUNG_Update]
    ON [dbo].[DIENSTLEISTUNG]
    FOR UPDATE
    AS
        IF UPDATE(PRICE) 
          ... (do what you need to do if PRICE is updated)...
    
        IF UPDATE(DESCRIPTION)
          ... (do what you need to do if DESCRIPTION is updated)...
    
        IF UPDATE(PRIORITY)
          ... (do what you need to do if PRIORITY is updated)...
    

    Use the UPDATE() function to check whether a given column has been updated – and if so, act on it. See the MSDN docs on how to use the UPDATE() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that is supposed to trigger anytime one of the
I have the following code being run if an iphone/ipad/ipod is detected: $('.tooltip-trigger').tooltip({offset: [20,
I have the following. I am trying to trigger the function based on the
I have the following script: ALTER TABLE ODANBIRM ADD (OBID NUMBER(10, 0) ); ----------------------------------------------------------------------------
I have to create a trigger (not procedure) to update subtotal, shipping_charge, tax and
I have the following scenario, action in window Window A triggers new window to
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.