A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi,@SPWGUT
Welcome to Microsoft T-SQL Q&A Forum!
Your code will update all columns equal to ID. If you want to update the specified column without affecting other columns, it is recommended to add a where condition directly:
Please try it:
CREATE TRIGGER trigger
ON SP_SW
AFTER INSERT
AS
update SP_SW
set table_column =SP_SW.id
from inserted
where id=inserted.id
As a reminder, please check whether your table has fields with the same name as the table. This is not very good. It is recommended to add a special symbol to mark it.For the use of triggers, you'd better refer to the official documentation.
Best regards,
Bert Zhou
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.