Blog Of Sem: sql server insert trigger basit yol

sql server insert trigger basit yol

Logo trigger ozel kod



https://www.youtube.com/watch?v=JFHKa3PEYuQ


CREATE TRIGGER KOD
ON LG_005_01_INVOICE
FOR INSERT
AS
DECLARE @GRPCODE INT, @SPECODE NVARCHAR(20), @LOGICALREF INT

SELECT @GRPCODE = GRPCODE, @SPECODE = SPECODE, @LOGICALREF = LOGICALREF FROM INSERTED

IF (@GRPCODE =1)
BEGIN
UPDATE LG_005_01_INVOICE SET SPECODE = 'ALIŞ' WHERE LOGICALREF = @LOGICALREF
END
ELSE
BEGIN
UPDATE LG_005_01_INVOICE SET SPECODE ='SATIŞ' WHERE LOGICALREF =@LOGICALREF
END