I have a function that takes 2 parameters and return a table.
Is it possible to use this function in a select and show the 3 columns that it returns?
This is my query:
select a.PersonId, b.Passportnumber, dbo.fn_Passport(a.PersonId)
from Person a
thanks
For SQL Server 2005+, you can use the APPLY operator
I have assumed the column names are col1, col2, col3 for illustration.
You use CROSS APPLY when the function must return 1 or more rows to retain the Person record. Use OUTER APPLY to keep the Person record even if the function results in no rows. Basically
How to use APPLY