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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

olibara
Yak Posting Veteran

94 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
30421 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  
 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.08 seconds. Powered By: Snitz Forums 2000