SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trigger to Prevent update if no changes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

olibara
Yak Posting Veteran

87 Posts

Posted - 07/10/2013 :  05:34:35  Show Profile  Reply with Quote
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

Sweden
30113 Posts

Posted - 07/10/2013 :  06:46:07  Show Profile  Visit SwePeso's Homepage  Reply with Quote
CREATE TRIGGER dbo.trgMyTrigger
ON dbo.MyTable
AFTER UPDATE
AS

SET NOCOUNT ON

IF NOT (UPDATE(A) AND UPDATE(B) AND UPDATE(C))
   ROLLBACK



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000