Hola !
Tengo un store procedure y una funcion en SQL Server, que
intento llevar el importe acumulado en cada linea.
Estos son
CREATE PROCEDURE [TBancosCuentasResumen]
(@IdCuenta [int])
AS
declare @Acumula money
Set @Acumula = 0
SELECT FechaSaldo,Importe, dbo.AcumuloSaldo(Operacion,
Importe, @Acumula) as Saldo
FROM TBancosCuentasDetalle
where IdCuenta = @IdCuenta
order by FechaSaldo
El Procedimiento recibe el IdCuenta y me muestra todos
los movimientos de esa cuenta, pero para mi sorpresa, no
me lleva el total acumulado. No encuentro el error.
La funcion AcumuloSaldo, seria la que me esta calculando
el total acumulado.
CREATE function AcumuloSaldo (
@Operador int,
@Importe money,
@Acumula money )
returns money
as
begin
Select @Acumula
Case @Operador
when 0 then @Acumula + @Importe
when 1 then @Acumula - @Importe
end
return @Acumula
end
Bueno, el que me pueda ayudar, desde ya le voy a estar
muy agradecido.
saludos a todos los foro
marcelo
Leer las respuestas