November 15, 2010 at 5:37 am
Hello Experts,
There are two Table Table_Trigger and Table_Trigger1.I have created a trigger on Table_Trigger1. It works perfectly.Below is my Trigger script -
CREATE TRIGGER Test_Trigger
ON Table_Trigger1
INSTEAD OF INSERT
AS
SET NOCOUNT ON
INSERT INTO Table_Trigger1(FirstName)
SELECT FirstName from INSERTED I
WHERE I.firstName in (SELECT FirstName from Table_Trigger)
when my where condition is true, I get a message (1 row(s) affected) and value save in Table.But when my where condition is false, that time I also get a message (1 row(s) affected) and value not save in Table.
My question is - If where condition is false and value don't save in table so why I got a (1 row(s) affected) message. what is meaning of this message.
Thanks in advance.
November 15, 2010 at 9:51 pm
mohitdahiya2 (11/15/2010)
My question is - If where condition is false and value don't save in table so why I got a (1 row(s) affected) message. what is meaning of this message.Thanks in advance.
The message "(1 row(s) affected)" is comming from the original INSERT statement. Not from the trigger. Because you have used SET NOCOUNT ON inside the trigger.
Also note that it is saying 1 row(s) "affected". Not 1 row(s) "saved".
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply