Trigger after update: How to execute query for every row updatedInsert Update trigger how to determine if insert or updateT-SQL Update trigger with multiple rowsDoes BEFORE INSERT trigger get executed for every row in “insert on duplicate key update” queryHow can I get an after update trigger to work when it is being fired from an after insert trigger in mysql?Trigger to Update TableAFTER UPDATE triggerHow to synchronize TRIGGER execution for UPDATE of certain row?SQL AFTER Insert Trigger for UpdateAFTER INSERT trigger causes query execution to hang upSQL trigger function to UPDATE daily moving average upon INSERT

In the MCU, why does Mjölnir retain its enchantments after Ragnarok?

How does turbine efficiency compare with internal combustion engines if all the turbine power is converted to mechanical energy?

Co-author responds to email by mistake cc'ing the EiC

Can pay be witheld for hours cleaning up after closing time?

Is there a limit on how long the casting (speaking aloud part of the spell) of Wish can be?

Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?

The teacher logged me in as administrator for doing a short task, is the whole system now compromised?

What is this symbol: semicircles facing eachother

IndexOptimize - Configuration

Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")

Why doesn't the Falcon-9 first stage use three legs to land?

How do I find the fastest route from Heathrow to an address in London using all forms of transport?

Justifying the use of directed energy weapons

Was Switzerland really impossible to invade during WW2?

How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?

How to compare two different formulations of a problem?

Fried gnocchi with spinach, bacon, cream sauce in a single pan

Three Singles in Three Clubs

System to validate run time complexity requirements

Is there such a thing as too inconvenient?

Is it insecure to have an ansible user with passwordless sudo?

How to write triplets in 4/4 time without using a 3 on top of the notes all the time

How to persuade recruiters to send me the Job Description?

Can I switch to third-person while not in 'town' in Destiny 2?



Trigger after update: How to execute query for every row updated


Insert Update trigger how to determine if insert or updateT-SQL Update trigger with multiple rowsDoes BEFORE INSERT trigger get executed for every row in “insert on duplicate key update” queryHow can I get an after update trigger to work when it is being fired from an after insert trigger in mysql?Trigger to Update TableAFTER UPDATE triggerHow to synchronize TRIGGER execution for UPDATE of certain row?SQL AFTER Insert Trigger for UpdateAFTER INSERT trigger causes query execution to hang upSQL trigger function to UPDATE daily moving average upon INSERT






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I wrote trigger to execute a query after the update of the column (retard) in my table, but sometimes there are many rows updated how to solve that?



CREATE OR ALTER TRIGGER notifRetard
ON Taches
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

DECLARE @value INT

IF UPDATE(retard)
-- How to make this for every row updated???
SELECT
@value = inserted.retard
FROM
inserted;

IF @value = 1
-- run SQL query
END












share|improve this question
































    0















    I wrote trigger to execute a query after the update of the column (retard) in my table, but sometimes there are many rows updated how to solve that?



    CREATE OR ALTER TRIGGER notifRetard
    ON Taches
    AFTER UPDATE
    AS
    BEGIN
    SET NOCOUNT ON;

    DECLARE @value INT

    IF UPDATE(retard)
    -- How to make this for every row updated???
    SELECT
    @value = inserted.retard
    FROM
    inserted;

    IF @value = 1
    -- run SQL query
    END












    share|improve this question




























      0












      0








      0








      I wrote trigger to execute a query after the update of the column (retard) in my table, but sometimes there are many rows updated how to solve that?



      CREATE OR ALTER TRIGGER notifRetard
      ON Taches
      AFTER UPDATE
      AS
      BEGIN
      SET NOCOUNT ON;

      DECLARE @value INT

      IF UPDATE(retard)
      -- How to make this for every row updated???
      SELECT
      @value = inserted.retard
      FROM
      inserted;

      IF @value = 1
      -- run SQL query
      END












      share|improve this question
















      I wrote trigger to execute a query after the update of the column (retard) in my table, but sometimes there are many rows updated how to solve that?



      CREATE OR ALTER TRIGGER notifRetard
      ON Taches
      AFTER UPDATE
      AS
      BEGIN
      SET NOCOUNT ON;

      DECLARE @value INT

      IF UPDATE(retard)
      -- How to make this for every row updated???
      SELECT
      @value = inserted.retard
      FROM
      inserted;

      IF @value = 1
      -- run SQL query
      END









      triggers sql-server-2017






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 7:19







      Manel Hkiri

















      asked Mar 27 at 16:07









      Manel HkiriManel Hkiri

      559 bronze badges




      559 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0













          The solution if someone else need it is to use CURSOR.



           CREATE or alter TRIGGER notifRetard
          ON Taches
          AFTER UPDATE

          AS
          BEGIN
          SET NOCOUNT ON;
          IF UPDATE(retard)
          begin
          DECLARE @RefTache varchar(50),@RefPhase numeric(4,0),@IDprojet varchar(50),@IDressource varchar(50) @retard bit;

          DECLARE TrigTempUpdate_Cursor CURSOR FOR

          SELECt RefTache,RefPhase,IDprojet,IDressource,retard
          FROM
          inserted;

          begin
          OPEN TrigTempUpdate_Cursor;

          FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard

          WHILE @@FETCH_STATUS = 0

          BEGIN
          if @retard=1
          --DO QUERY HERE
          FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard
          END;
          end;
          CLOSE TrigTempUpdate_Cursor;

          DEALLOCATE TrigTempUpdate_Cursor;

          end;
          end;





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381748%2ftrigger-after-update-how-to-execute-query-for-every-row-updated%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0













            The solution if someone else need it is to use CURSOR.



             CREATE or alter TRIGGER notifRetard
            ON Taches
            AFTER UPDATE

            AS
            BEGIN
            SET NOCOUNT ON;
            IF UPDATE(retard)
            begin
            DECLARE @RefTache varchar(50),@RefPhase numeric(4,0),@IDprojet varchar(50),@IDressource varchar(50) @retard bit;

            DECLARE TrigTempUpdate_Cursor CURSOR FOR

            SELECt RefTache,RefPhase,IDprojet,IDressource,retard
            FROM
            inserted;

            begin
            OPEN TrigTempUpdate_Cursor;

            FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard

            WHILE @@FETCH_STATUS = 0

            BEGIN
            if @retard=1
            --DO QUERY HERE
            FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard
            END;
            end;
            CLOSE TrigTempUpdate_Cursor;

            DEALLOCATE TrigTempUpdate_Cursor;

            end;
            end;





            share|improve this answer





























              0













              The solution if someone else need it is to use CURSOR.



               CREATE or alter TRIGGER notifRetard
              ON Taches
              AFTER UPDATE

              AS
              BEGIN
              SET NOCOUNT ON;
              IF UPDATE(retard)
              begin
              DECLARE @RefTache varchar(50),@RefPhase numeric(4,0),@IDprojet varchar(50),@IDressource varchar(50) @retard bit;

              DECLARE TrigTempUpdate_Cursor CURSOR FOR

              SELECt RefTache,RefPhase,IDprojet,IDressource,retard
              FROM
              inserted;

              begin
              OPEN TrigTempUpdate_Cursor;

              FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard

              WHILE @@FETCH_STATUS = 0

              BEGIN
              if @retard=1
              --DO QUERY HERE
              FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard
              END;
              end;
              CLOSE TrigTempUpdate_Cursor;

              DEALLOCATE TrigTempUpdate_Cursor;

              end;
              end;





              share|improve this answer



























                0












                0








                0







                The solution if someone else need it is to use CURSOR.



                 CREATE or alter TRIGGER notifRetard
                ON Taches
                AFTER UPDATE

                AS
                BEGIN
                SET NOCOUNT ON;
                IF UPDATE(retard)
                begin
                DECLARE @RefTache varchar(50),@RefPhase numeric(4,0),@IDprojet varchar(50),@IDressource varchar(50) @retard bit;

                DECLARE TrigTempUpdate_Cursor CURSOR FOR

                SELECt RefTache,RefPhase,IDprojet,IDressource,retard
                FROM
                inserted;

                begin
                OPEN TrigTempUpdate_Cursor;

                FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard

                WHILE @@FETCH_STATUS = 0

                BEGIN
                if @retard=1
                --DO QUERY HERE
                FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard
                END;
                end;
                CLOSE TrigTempUpdate_Cursor;

                DEALLOCATE TrigTempUpdate_Cursor;

                end;
                end;





                share|improve this answer













                The solution if someone else need it is to use CURSOR.



                 CREATE or alter TRIGGER notifRetard
                ON Taches
                AFTER UPDATE

                AS
                BEGIN
                SET NOCOUNT ON;
                IF UPDATE(retard)
                begin
                DECLARE @RefTache varchar(50),@RefPhase numeric(4,0),@IDprojet varchar(50),@IDressource varchar(50) @retard bit;

                DECLARE TrigTempUpdate_Cursor CURSOR FOR

                SELECt RefTache,RefPhase,IDprojet,IDressource,retard
                FROM
                inserted;

                begin
                OPEN TrigTempUpdate_Cursor;

                FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard

                WHILE @@FETCH_STATUS = 0

                BEGIN
                if @retard=1
                --DO QUERY HERE
                FETCH NEXT FROM TrigTempUpdate_Cursor INTO @RefTache, @RefPhase,@IDprojet,@IDressource,@retard
                END;
                end;
                CLOSE TrigTempUpdate_Cursor;

                DEALLOCATE TrigTempUpdate_Cursor;

                end;
                end;






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 8:46









                Manel HkiriManel Hkiri

                559 bronze badges




                559 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381748%2ftrigger-after-update-how-to-execute-query-for-every-row-updated%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript