Procedimiento almacenado:

CREATE PROCEDURE [dbo].[PDameImportesFactura]
@IdFactura T_Id_Factura,
@Anyo int OUTPUT,
@Mes int OUTPUT,
@PVP Float OUTPUT,
@Precio_Total Float OUTPUT
AS
----------------------------------------------------------------------------------------------------
-- procedimiento para devolver datos de factura
----------------------------------------------------------------------------------------------------
BEGIN
-- comprobar si se ha especificado la factura
IF @IdFactura IS NULL BEGIN
PRINT 'No se ha especificado la factura.'
RETURN 0
END
-- rellenar variables salida
SELECT @Anyo=YEAR(F.FechaFact),
@Mes=MONTH(F.FechaFact),
@PVP=SUM(l.Precio_EURO * (1-L.Descuento/100.0) * (1-F.Descuento/100.0) * (1-F.DescuentoPP/100.0)),
@Precio_Total=SUM(L.Cantidad * L.Precio_EURO * (1-L.Descuento/100.0) * (1-F.Descuento/100.0) * (1-F.DescuentoPP/100.0))
FROM Pedidos_Cli_Lineas L INNER JOIN Facturas_Cli_Cab F ON L.IdFactura=F.IdFactura
WHERE F.IdFactura=@IdFactura
GROUP BY F.IdFactura,F.FechaFact
-- retorno
RETURN -1
END
-- llamada
Declare @Anyo int
Declare @Mes int
Declare @PVP Float
Declare @Precio_Total Float
Declare @ret int
EXEC @re t= PDameImportesFactura 24, @Anyo OUTPUT, @Mes OUTPUT, @PVP OUTPUT, @Precio_Total OUTPUT
PRINT @Anyo
PRINT @Mes<
PRINT @PVP
PRINT @Precio_Total
PRINT @ret