DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to block a column update with a trigger?

The following trigger will block updates on the NationalIDNumber column in the Employee table. It can be used for business rule enforcement.

USE AdventureWorks2008;

GO

CREATE TRIGGER trgHRSSNBlock

ON HumanResources.Employee

FOR UPDATE

AS

  IF UPDATE(NationalIDNumber)

    BEGIN

      RAISERROR ('SSN cannot be updated',10,1)

      ROLLBACK TRANSACTION

    END

GO

 

-- The following update statement will be rolled back:

UPDATE HumanResources.Employee

SET    NationalIDNumber = '123-46-7890'

WHERE  EmployeeID = 7

GO

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE