Is it possible to pass a table to a UDF?
I assumed you could do it, but when I try I get an error.
For example
Gives me:
Msg 156, Level 15, State 1, Procedure Tdistance, Line 1
Incorrect syntax near the keyword 'Table'.
Msg 1087, Level 15, State 2, Procedure Tdistance, Line 7
Must declare the table variable "@TIDs".
Msg 178, Level 15, State 1, Procedure Tdistance, Line 8
A RETURN statement with a return value cannot be used in this context.
I assumed you could do it, but when I try I get an error.
For example
Code:
Create Function dbo.Tdistance(@Trank smallint, @TIDs Table(Trank smallint))
Returns Real as
Begin
declare @value real
select @value = Sum(1/(radius*radius))
From HIxD
Where frum in (select * from @TIDs) and tu=@trank
Return @value
End
Gives me:
Msg 156, Level 15, State 1, Procedure Tdistance, Line 1
Incorrect syntax near the keyword 'Table'.
Msg 1087, Level 15, State 2, Procedure Tdistance, Line 7
Must declare the table variable "@TIDs".
Msg 178, Level 15, State 1, Procedure Tdistance, Line 8
A RETURN statement with a return value cannot be used in this context.