I want to pass a table variable to a fuction (which would contains different value at different time) as input, returning a calculated result in the form of another table, which would be declared in the function.
Something like this:
CREATE FUNCTION fn_CalculateListing(@ListingData TABLE(ROWID INT,value1 INT, value2 INT)) RETURNS TABLE AS BEGIN DECLARE @result TABLE ( result1 INT, result2 INT ) INSERT INTO @result(result1,result2) SELECT value1*value2, value1/value2 FROM ListingDate RETURN @result END
But the above syntax give me an error near declaration
@ListingDate TABLE as incorrect syntax.
Is above syntax correct, or should I use another one?