Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be the table contain updated row for update trigger

A while ago i read the article for Trigger in SQL Server, and it said that i can use the Logical Table "Updated" for updated rows... And i got error:

System.Data.SqlClient.SqlException: Invalid object name 'Updated'.

After a while of google, i found out some more post that said only 2 logical tables available are: Inserted and Deleted...

I'm confused... What should i use since my Trigger rely on the Updated table that contain the updated row, and use it to insert to another table or the same table with new PK...

Thank you very much

like image 428
DucDigital Avatar asked Dec 20 '09 12:12

DucDigital


People also ask

How do I know which column is updated in a trigger?

SQL Server COLUMNS_UPDATED() Function for Triggers. This function is used to know the inserted or updated columns of a table or view. It returns a VARBINARY stream that by using a bitmask allows you to test for multiple columns.

Can we update same table in trigger?

Is there any way I can make this work? Thanks everyone! Trigger can NOT alter the table which altering fires this thigger. No exclusions.

How do I create a trigger update in MySQL?

Introduction to MySQL AFTER UPDATE triggers In this syntax: First, specify the name of the trigger that you want to create in the CREATE TRIGGER clause. Second, use AFTER UPDATE clause to specify the time to invoke the trigger. Third, specify the name of the table to which the trigger belongs after the ON keyword.


1 Answers

The two dummy tables are called Inserted (available in INSERT and UPDATE triggers) and Deleted (available in DELETE and UPDATE triggers).

There is no Updated dummy table in SQL Server triggers.

For an FOR UPDATE trigger, the Deleted table contains the old values, while the Inserted table contains the new ones.

Marc

like image 185
marc_s Avatar answered Sep 29 '22 11:09

marc_s