Sql server trigger if updating
Using the clause WHERE Order Status='Approved' by itself to limit the rows updated will actually result in all rows with an Order Status value of Approved being updated at the same time.
Please see my answer for explanation as well as info on how to accomplish what you are wanting to do :-). I need to create a SQL Server trigger that will execute when a column value is updated to a specific value. In this tip, we show you how to write T-SQL statements that will create a SQL Server trigger that will execute after we update a column value to a specific value.In the image below we see where we create our example table named tbl Trigger Test with a primary key column named pk ID, a date column named Order Approval Date Time and a varchar column named Order Status.Would it introduce any issues in the system or not depends on implementation.
However, it would always lead to unnecessary performance overhead. The code below creates another table and changes trigger in a way, that mimics behavior of audit functional, which is frequently implemented based on triggers. Audit ( ID int not null identity(1,1), On Date datetime2(0) not null constraint DEF_Audit_On Date default getutcdate(), Message varchar(64) not null, ) go alter trigger trg Data_AI on dbo.Again, this is our desired behavior and all appears well.