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;
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
add a comment |
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
add a comment |
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
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
triggers sql-server-2017
edited Mar 28 at 7:19
Manel Hkiri
asked Mar 27 at 16:07
Manel HkiriManel Hkiri
559 bronze badges
559 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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;
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
add a comment |
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;
add a comment |
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;
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;
answered Mar 28 at 8:46
Manel HkiriManel Hkiri
559 bronze badges
559 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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