﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Tiago Silva / Article Discussions / Article Discussions by Author  / Trigger defined for Insert, Update / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 03:11:17 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Trigger defined for Insert, Update</title><link>http://www.sqlservercentral.com/Forums/Topic434953-259-1.aspx</link><description>You could do something like:[code="sql"]   DECLARE @operation as Varchar(10);   DECLARE @Count as int;   SET @operation = 'Inserted';   SELECT @Count = COUNT(*) FROM DELETED;   if @Count &amp;gt; 0      BEGIN         SET @operation = 'Deleted';         SELECT @Count = COUNT(*) FROM INSERTED;         IF @Count &amp;gt; 0            SET @operation = 'Updated'      END[/code]HTH,Rob</description><pubDate>Wed, 12 Sep 2012 21:54:32 GMT</pubDate><dc:creator>robert.gerald.taylor</dc:creator></item><item><title>RE: Trigger defined for Insert, Update</title><link>http://www.sqlservercentral.com/Forums/Topic434953-259-1.aspx</link><description>If your trigger is For Update, Insert there is not any system information identifying what action caused the trigger to fire.You could duplicate your code, and create 1 trigger for insert, and 1 trigger for update, or test for Existing rows as you mentioned.</description><pubDate>Wed, 19 Dec 2007 15:04:32 GMT</pubDate><dc:creator>Ray M</dc:creator></item><item><title>Trigger defined for Insert, Update</title><link>http://www.sqlservercentral.com/Forums/Topic434953-259-1.aspx</link><description>Is there an "easy/quick" way to determine inside the trigger itself whether it is being fired because of an Insert or because of an Update when a trigger has been defined for Insert, Update?Without inquiring whether a row exists or not, is there a system variable that can determine this?</description><pubDate>Wed, 19 Dec 2007 13:35:47 GMT</pubDate><dc:creator>bob pearson-184607</dc:creator></item></channel></rss>