SQL Server 2008 table variable error: Must declare the scalar variable "@RESULT".
Posted
by Trindaz
on Stack Overflow
See other posts from Stack Overflow
or by Trindaz
Published on 2010-03-23T00:23:21Z
Indexed on
2010/03/23
0:31 UTC
Read the original article
Hit count: 504
I'm using table values for the first time as a parameter to a function in SQL Server 2008. The code below produces this error:
Must declare the scalar variable "@RESULT".
Why?! I'm declaring it on the first line of the function!
ALTER FUNCTION f_Get_Total_Amount_Due(
@CUSTOMER_LIST [tpCSFM_CUSTOMER_SET_FOR_MONEY] READONLY
)
RETURNS [tpCSFM_CUSTOMER_SET_FOR_MONEY]
AS
BEGIN
--Prepare the return value, start with initial customer list
DECLARE @RESULT AS [tpCSFM_CUSTOMER_SET_FOR_MONEY]
INSERT INTO @RESULT SELECT * FROM @CUSTOMER_LIST
--Todo: populate with real values
UPDATE @RESULT SET tpCSAM_MONEY_VALUE = 100
--return total amounts as currency
RETURN @RESULT
END
© Stack Overflow or respective owner