A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Create table tbl_GRN_Detail (D_ID int,GRN_ID int,item_code int,Issue_ID int)
Insert into tbl_GRN_Detail values (11001,2001,22,Null)
Create table tbl_issuance (issue_ID int,item_code int,Issue_Date date,D_ID int)
go
CREATE TRIGGER issuance_tri ON tbl_issuance AFTER INSERT AS
UPDATE tbl_GRN_Detail
SET Issue_ID = i.issue_ID
FROM tbl_GRN_Detail G
JOIN inserted i ON G.D_ID = i.D_ID
go
Insert into tbl_issuance values (101,22,'2021-06-28',11001)
go
SELECT * FROM tbl_GRN_Detail
go
DROP TABLE tbl_GRN_Detail
DROP TABLE tbl_issuance
In a trigger, you have access to the virtual tables inserted and deleted. inserted holds the inserted rows by an INSERT statement and an afterimage of the rows for an UPDATE statement.