Multiple select statement in stored procedure
- by GigaPr
Hi,
i have a stored procedure that has to retrieve data from multiple tables
something like
SELECT [AppointmentId]
,[ContactId]
,[Date]
,[BookedBy]
,[Details]
,[Status]
,[Time]
,[Type]
,[JobId]
,[AppointmentFor]
,(Select PersonFirstName from Person where Person_Id = [AppointmentFor]) As UserFirstName
,(Select PersonLastName from Person where Person_Id = [AppointmentFor]) As UserLastName
,(Select PersonFirstName from Person where Person_Id = [ContactId]) As ContactFirstName
,(Select PersonLastName from Person where Person_Id = [ContactId]) As ContactLastName
FROM [dbo].[Appointments]
my question is
there is any other more efficient way to do this? Or is this the right approach?
I am working on a Sql server 2008
Thanks