Hi,@Muhammad Ali
Please check this:
create table #test(Account nvarchar(30),
DR money,
CR money,
Balance money
)
insert into #test values('XY Co.',200,200,null),('XY Co.',400,-200,null),('XY Co.',300,100,null)
select * from #test
IF OBJECT_ID('proc_test')IS NOT NULL
DROP PROC proc_test;
GO
CREATE PROC proc_test
AS
update #test
set Balance=DR-CR
EXEC proc_test
select * from #test
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.