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 8478707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:49:09+00:00 2026-06-10T18:49:09+00:00

By looking at other examples I’ve come up with the following but it doesn’t

  • 0

By looking at other examples I’ve come up with the following but it doesn’t seem to work as I would like: I want it to only update the modified information if the QtyToRepair value has been updated… but it doesn’t do that.

If I comment out the where then the modified information is updated in every case. As I said other examples led me to be optimistic. Any clues appreciated. Thanks.

Walter

ALTER TRIGGER [dbo].[tr_SCHEDULE_Modified]
   ON [dbo].[SCHEDULE]
   AFTER UPDATE
AS 
BEGIN
    SET NOCOUNT ON;

    UPDATE SCHEDULE SET modified = GETDATE()
        , ModifiedUser = SUSER_NAME()
        , ModifiedHost = HOST_NAME()
    FROM SCHEDULE S
    INNER JOIN Inserted I on S.OrderNo = I.OrderNo and S.PartNumber = I.PartNumber
    WHERE S.QtyToRepair <> I.QtyToRepair
END
  • 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-10T18:49:10+00:00Added an answer on June 10, 2026 at 6:49 pm

    You have two way for your question :

    1- Use Update Command in your Trigger.

    ALTER TRIGGER [dbo].[tr_SCHEDULE_Modified]
       ON [dbo].[SCHEDULE]
       AFTER UPDATE
    AS BEGIN
        SET NOCOUNT ON;
        IF UPDATE (QtyToRepair) 
        BEGIN
            UPDATE SCHEDULE 
            SET modified = GETDATE()
               , ModifiedUser = SUSER_NAME()
               , ModifiedHost = HOST_NAME()
            FROM SCHEDULE S INNER JOIN Inserted I 
            ON S.OrderNo = I.OrderNo and S.PartNumber = I.PartNumber
            WHERE S.QtyToRepair <> I.QtyToRepair
        END 
    END
    

    2- Use Join between Inserted table and deleted table

    ALTER TRIGGER [dbo].[tr_SCHEDULE_Modified]
       ON [dbo].[SCHEDULE]
       AFTER UPDATE
    AS BEGIN
        SET NOCOUNT ON;    
    
        UPDATE SCHEDULE 
        SET modified = GETDATE()
           , ModifiedUser = SUSER_NAME()
           , ModifiedHost = HOST_NAME()
        FROM SCHEDULE S 
        INNER JOIN Inserted I ON S.OrderNo = I.OrderNo and S.PartNumber = I.PartNumber
        INNER JOIN Deleted D ON S.OrderNo = D.OrderNo and S.PartNumber = D.PartNumber                  
        WHERE S.QtyToRepair <> I.QtyToRepair
        AND D.QtyToRepair <> I.QtyToRepair
    END
    

    When you use update command for table SCHEDULE and Set QtyToRepair Column to new value, if new value equal to old value in one or multi row, solution 1 update all updated row in Schedule table but solution 2 update only schedule rows that old value not equal to new value.

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

Sidebar

Related Questions

I saw many examples and tried to follow but none of them would work.
I've seen a few other examples of this for SQL, but I am looking
Is it possible to change the default text (something like looking for other iPhones
Looking at some examples, I came across lines like: output.safe_concat(<input type=\hidden\ id=\#{k}\ name=\#{CGI.escape(k)}\ value=\#{CGI.escape(v)}\/>)
I'm writing an nginx module. From looking at other examples I'm registering my header
I am looking to inherite a enumaration in other one: for example: Type TMyTypeKind
Been looking through other answers and I still don't understand the modulo for negative
After looking a while other google, and the web, I decided to post my
Looking for the correct preg_match (or other solution) to validate a string to go
I'm looking for feedback on what other people use on their ASP.NET projects to

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.