declare @PriceBankMeli bigint
select @PriceBankMeli = SUM(Price) from dbo.table1 where BankName = N'بانک ملی'
@PriceInput bigint
if (@PriceInput> @PriceBank )
begin
Set @Result = N'مبلغ وارده بیشتر از موجودی حساب می باشد'
end
else begin
begin tran t1
Declare @PriceBankMelat
select @PriceBankMelat = sum(Price) from dbo.Table1 where BankName = N'بانک ملت'
Set @PriceBankMelat = @PriceBankMelat + @PriceInput-- Input
update dbo.Table1
set [Price] = @PriceBankMelat
where BankName = N'بانک ملت'
update dbo.Table1
Set [Price] = @PriceBankMeli - @PriceInput
where BankName = N'بانک ملی'
if @@Error = 0
Commit tran t1
else
Rollback tran t1
end
امیدوارم تونسته باشم کمکی کرده باشم
آخه من خودم هم درگیر یه پروژه مالی هستم خود من هم دیگه قاطی کردم
توسط
baharbin
(741 امتیاز)
●1 ●14 ●52