Getting Started with Adobe After Effects - Part 6: Motion Blur

Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Trigger and number of rows affected

Mar 21 2011 6:50AM by Madhivanan   

One of my frieds told me that INSERT trigger will not fire if no data are added to the main table. It is a mistake that some people think that triggers will not fire if no row is affected. Note that trigger is event based and not data based.

Here is a proof that trigger fires eventhough no row is affected.

Consider this table

create table testing(prod_id int , prod_name varchar(100))

and create this trigger

create trigger test_trigger on testing
for insert
raiserror ('The insert trigger is fired',10,16)

Now execute the following code that adds no row to the table

insert into testing(prod_id ,prod_name )
select 1,'test' where 1=0

The message retuned is

The insert trigger is fired

(0 row(s) affected)

So it is clear that when a statement is valid, trigger will fire no matter how many rows are actually affected

Tags: t-sql, sql_server, sqlserver, tsql, BRH, #TSQL, #SQLServer, trigger,

2 · 40% · 13039



  • This seems to be a common misconception - how it started I don't know, but a couple of months ago, I heard a few interns saying the same thing. Thank-you for this post, Madhivanan. Now I know where to direct them to next time it happens.

    commented on Apr 9 2011 5:41AM
    Nakul Vachhrajani
    4 · 36% · 11648
  • Thanks for the feedback Nakul

    commented on Apr 12 2011 4:06AM
    2 · 40% · 13039

Your Comment

Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]