CREATE TRIGGER [dbo].[TR_dbo_GlLoan_LoanNumber] ON [dbo].[GlLoan] AFTER INSERT
AS
BEGIN
if @@ROWCOUNT = 0
return
SET NOCOUNT ON;
declare @count int;
set @count= (select max(loannumber) from glloan where branchid=(select branchid from inserted) and CompanyId=(select CompanyId from inserted))
update glloan set loannumber=@count+1 where id=(select id from inserted)
END
GO
Is there any chance where loan number can be duplicated for a given branch and company?
Aucun commentaire:
Enregistrer un commentaire