April 6, 2025 at 4:09 pm
Hi Guys
I have a store proc that delete a row from a and I would like to get the result of the deleted row whether be =1 or True in order to execute another store proc. Could this be possible?
---- I am aware this code won't work I am trying to explain what I would like to accomplish
DECLARE @RowToDelete int,@Result int
SET @RowToDelete=1
SELECT @Result=(DELETE from table where Id=@RowToDelete)
IF @Result=1 --- Or whatever rusults is
BEGIN
EXEC('storeproc @param1, @param2)
END
Only if the deleted row is true then execute the store proc.
TIA
AL
April 6, 2025 at 4:29 pm
CREATE TRIGGER TriggerName
ON YourTableName
AFTER DELETE
AS
BEGIN
-- -- Check if any row was deleted (= 1 or True)
IF EXISTS (SELECT 1 FROM DELETED)
BEGIN
-- Execute your stored procedure
EXEC YourStoredProcedureName;
END;
END;
April 6, 2025 at 4:56 pm
Try something like this ...
DECLARE @RowToDelete int,@Result int;
SET @RowToDelete=1;
DELETE from table where Id=@RowToDelete;
SELECT @Result = @@ROWCOUNT;
IF @Result=1 --- Or whatever rusults is
BEGIN
EXEC storeproc @param1, @param2;
END
April 8, 2025 at 6:53 pm
I would lean towards DesNorton's solution as I dislike triggers and I think they get hidden/lost from future devs/DBAs.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy