One question, why you use @pais a parameter if you don't use the parameter into the function??? the solution was simple, only put money instead to decimal en the function table and everything works fine, but as I know that you can't do that here is the function in the format that you need:
Código SQL:
Ver originalALTER FUNCTION m_ventaPtos(@pais VARCHAR(500))
RETURNS @monto TABLE (Pais VARCHAR(500),[1996] money,[1997] money,[1998] money)
AS
BEGIN
INSERT @monto
SELECT shipcountry AS PAIS, isnull(SUM([1996]),0) AS [1996],isnull(SUM([1997]),0) AS [1997],isnull(SUM([1998]),0) AS [1998] FROM
(
SELECT
CASE WHEN datepart(yyyy,OrderDate)=1996 THEN SUM(total) END AS [1996],
CASE WHEN datepart(yyyy,OrderDate)=1997 THEN SUM(total) END AS [1997],
CASE WHEN datepart(yyyy,OrderDate)=1998 THEN SUM(total) END AS [1998],
ShipCountry
FROM(
SELECT
OrderDate,(UnitPrice * Quantity) AS total, ShipCountry
FROM [ORDER Details] AS t1
LEFT JOIN Orders AS t2 ON (t1.OrderID=t2.OrderID)
) AS t1
GROUP BY ShipCountry,orderdate
) AS t2 GROUP BY ShipCountry
RETURN
END
SELECT * FROM m_ventaPtos('Argentina')
Reagrds,
Libras