How to Pass a Parameter to a Query with UDF

SmallTime

Registered User.
Local time
Today, 04:58
Joined
Mar 24, 2011
Messages
246
I'm petty new, well very new if truth be told, to SQL Server and need some help passing a parameter in a query that's made of two tables and a parametized UDF

This is what I have:

Code:
select *
from 
TblRef AS r
inner join TblAllo AS a
ON r.refCN = a.alloCN inner join GETSelectedSite(@SelSite) AS ss
ON r.refCN = ss.refCN


Tblref is a atable
TblAllo is a Table
GETSelectedSite is parametrized UDF where the patameter name is @SelSite

I can run the UDF OK by itself and the above works if I explicity include the parameter @SelSite eg.

Code:
select *
from 
TblRef AS r
inner join TblAllo AS a
ON r.refCN = a.alloCN inner join GETSelectedSite('SiteA') AS ss
ON r.refCN = ss.refCN

However, that defeats the purpose of a variable so any guidance or help would be very much appreciated.

Many Thanks
SmallTime
 

Users who are viewing this thread

Back
Top Bottom