Triger update not working

Hello ,

I Created a triger but not working
Idont understand where is the issue ?

Can you help me ?

My Triger ;

USE [LOGODB]
GO
/****** Object: Trigger [dbo].[CurrAcc] Script Date: 9.09.2023 13:33:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[CurrAcc]

ON [dbo].[LG_020_01_ORFLINE]

AFTER UPDATE

AS

BEGIN

UPDATE

ORFLINE

SET ORFLINE.SPECODE2 = OkulKoduSiparisCat.Cari_Kodu

FROM LG_020_01_ORFLINE AS ORFLINE

LEFT OUTER JOIN LG_020_01_ORFICHE AS ORFICHE ON ORFLINE.ORDFICHEREF = ORFICHE.LOGICALREF

INNER JOIN MYSQL...OkulKoduSiparisCat ON OkulKoduSiparisCat.Siparis_NO = ORFICHE.DOCODE

END

Just Update Working

Update Query ;
UPDATE

ORFLINE

SET ORFLINE.SPECODE2 = OkulKoduSiparisCat.Cari_Kodu

FROM LG_020_01_ORFLINE AS ORFLINE

LEFT OUTER JOIN LG_020_01_ORFICHE AS ORFICHE ON ORFLINE.ORDFICHEREF = ORFICHE.LOGICALREF

INNER JOIN MYSQL...OkulKoduSiparisCat ON OkulKoduSiparisCat.Siparis_NO = ORFICHE.DOCODE

hi hope this helps

sql server - Update the same table in the trigger - Stack Overflow

another idea is
INSTEAD of TRIGGER

You need to use pseudo-table "inserted" in the trigger query, otherwise you'll update the whole table. Also, if any row doesn't match the JOIN to OkulKoduSiparisCat , that row won't be updated. You almost certainly need to add the database name on that JOIN.


UPDATE
ORFLINE
SET ORFLINE.SPECODE2 = OkulKoduSiparisCat.Cari_Kodu
FROM LG_020_01_ORFLINE AS ORFLINE
INNER JOIN inserted AS i ON i.?key_col? = ORFLINE.?key_col?
LEFT OUTER JOIN LG_020_01_ORFICHE AS ORFICHE ON ORFLINE.ORDFICHEREF = ORFICHE.LOGICALREF
INNER JOIN MYSQL.?database_name?.dbo.OkulKoduSiparisCat ON OkulKoduSiparisCat.Siparis_NO = ORFICHE.DOCODE