Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is code I used to create function which accept table as input and after operaton within function return result in table format as:
SQL
CREATE FUNCTION fn_CalculateListing(@Listing ListingColumn READONLY)
RETURNS TABLE 
AS
BEGIN
    DECLARE @result TABLE (ID INT, Name VARCHAR(50))

    INSERT INTO @result(ID,Name)
        SELECT ROWID, Name
        FROM @Listing

    RETURN @Listing
END


I have make use of table-inline parameter but gives error as:

SQL
Msg 137, Level 15, State 2, Procedure fn_CalculateListing, Line 16
Must declare the scalar variable "@Listring".

Msg 102, Level 15, State 31, Procedure fn_CalculateListing, Line 29
Incorrect syntax near 'BEGIN'.`


How can I make it correct?
Posted
Updated 23-Jan-16 0:26am
v5
Comments
Richard MacCutchan 23-Jan-16 6:21am    
Go to those two lines in your file and correct the typos.

1 solution

Your procedure syntax is correct. It should work
However, You are passing the incorrect variable

see the error message -
Must declare the scalar variable "@Listring".

It says issue with "Listring" whereas in your procedure you have used "Listing"

Make sense?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900