Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Table Variable to UDF

Status
Not open for further replies.

Fhwqhgads

Programmer
Jan 6, 2007
13
US
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
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.
 
No you can not. You have to pass values only.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top