Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trigger to Prevent update if no changes

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2013-07-10 : 05:34:35
Hello

Is it possible to create a trigger to prevent update of a row if no signifiant colums are updated

Example : I need to allow the update only if colums a,b or c have changes ?

I've seen INSTEAD OF UPDATE but I do not really understand how it should works to keep or discard the update according to condition ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-07-10 : 06:46:07
[code]CREATE TRIGGER dbo.trgMyTrigger
ON dbo.MyTable
AFTER UPDATE
AS

SET NOCOUNT ON

IF NOT (UPDATE(A) AND UPDATE(B) AND UPDATE(C))
ROLLBACK[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -