Multiple select statement in stored procedure
Posted
by GigaPr
on Stack Overflow
See other posts from Stack Overflow
or by GigaPr
Published on 2010-03-18T11:00:46Z
Indexed on
2010/03/18
11:11 UTC
Read the original article
Hit count: 294
sql
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
© Stack Overflow or respective owner