Microsoft SQL Server
--
Questions
--
Followers
Top Experts
I need to change an update trigger in SQL Server 2008 to silently reject any attempts to change a single column value. The user may issue UPDATE statements which are updating numerous columns. I need to stop them from changing one column in particular, but I do not want to raise an error.
I tried using the deleted table to restore the original column value, but I cannot get it to work. Chances are I'd get a dangerous loop going, anyway. I also considered an INSTEAD OF trigger, but I'd that to be my last resort.
So, imagine I have this table:
TableA
ColumnUID Â INTEGER PK
ColumnA Â Â CHAR(10)
ColumnB Â Â CHAR(100)
The user may issue this statement:
UPDATE TableA
SET ColumnA = 'ABC'
, ColumnB = 'Winter Park'
WHERE ColumnUID = 123;
I want the trigger to allow the ColumnB change to occur, but reject the change on ColumnA. It needs to be silent.
IF UPDATE(ColumnA)
BEGIN
  << Do not actually change ColumnA >>
END
Any assistance would be appreciated.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Microsoft SQL Server
--
Questions
--
Followers
Top Experts
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.