April 22, 2010 at 2:41 pm
I thought this was possible but darned if i can figure out how to do it.
I also am not sure how to properly word this so forgive me if it takes a few tries.
Is there a way to pass to the Paramater of a UDF, a TABLE.Column reference and not a literal value?
I know that if I have a UDF that as an example will return a table of Phone number info for the person you pass to it via its @MyPerson parameter I can do something like this:
SELECT P.*
FROM dbo.udfPhoneNums('jon.doe') P
And the UDF will return 1 row for each phone number linked to 'Job.doe'. How then can I expand this so that instead of passing the literal name of 'Jon.Doe' to the UDF's param I can instead specify a TABLE.Column so that in effect, the UDF will retunr rows for every @MyPerson passed to it.
A pseducode of what I'm trying to explain might be something like this:
SELECT T.sName, P.*
FROM MYPERSONSTABLE T Join dbo.udfPhoneNums(T.sName) P ON T.sName = P.sName
Right now the UDF I'm working with will return 1 to many rows of info for each person passed to its 1 paramater. I'm trying to find a way to use the UDF but with many Names by joining the UDF to a table of Names. I realize this may not be doable but I swear I recall seeing it somehwere before.
Again I apolagize if this is not properly explained but I'm not sure how to best ask. I don't have a udfPhoneNums() function but I can't provide the DDL on what I am using because of NDA restrictions.
Kindest Regards,
Just say No to Facebook!April 23, 2010 at 5:21 am
Try o use the APPLY operator
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply