Person
table - PersonId, PersonName, etc.. (~1200 records)Two user functions - GetPersonAddress(@PersonId)
, GetPaymentAddress(@PersonId)
These two functions return data in a table with Street, City etc...(one record in the return table for the PersonId
)
I have to create a view that joins the person table with these two user functions by passing in the person id.
Limitations:
Can someone help?
You could create functions GetPeopleAddresses()
and GetPaymentsAddresses()
which return PersonId as a field and then you can use them in JOIN
:
SELECT t.PersonId, PersonName, etc..., a1.Address, a2.Address
FROM YourTable t
LEFT JOIN GetPeopleAddresses() a1 ON a1.PersonId = t.PersonId
LEFT JOIN GetPaymentsAddresses() a2 ON a2.PersonId = t.PersonId
Of course, your functions have to return only unique records