A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi,@Analyst_SQL
How about modify [dbo].[SP_Inert_GRN],use left join when insert.
Or maybe have a try on Trigger like this:
IF OBJECT_ID('tri_AfterInsert')IS NOT NULL
DROP TRIGGER tri_AfterInsert
GO
CREATE TRIGGER tri_AfterInsert ON tbl_GRN_Detail
AFTER INSERT
AS
UPDATE tbl_GRN_Detail
SET G_DID = CONCAT('G-',stuff(G_DID, 1, 2, '') +(SELECT COUNT(GRN_ID) FROM tbl_GRN_Detail WHERE GRN_ID=@GRN_ID))
Best regards,
LiHong
----------
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.