Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trigger firiring with no changes 1

Status
Not open for further replies.

csmeutah

IS-IT--Management
Mar 1, 2005
33
0
0
US
I have some triggers that fire when a column in a row is changed to the same value it already contained. In other words the inserted and deleted tables are exactly the same. Is there a low overhead way of checking for no real changes other than by comparing each column in both the inserted and deleted tables?

I have always checked a count of the inserted table before my trigger code, would that evaluate to 0 if no real change? Otherwise when would an inserted table not have any rows during the firing of a trigger?

TIA

 
Inserted would only have 0 rows if you are doing a delete.

SQL Server would consider it an update even if no data changed if the update stament ran. So if you updated with this statement:
Code:
update tablea
set field1 = 'test'
where field1 = 'test'

There would still be a record in inserted and deleted even though there was no change.

Personally I would compare the columns in the insert, update or delete statment you are running in the trigger.

"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top