I prefer to code in t-sql using what is actually an inline join rather than having a long list of joins at the end of the stored procedure or view.
For example, I have the code:
SELECT PKey , Billable, (SELECT LastName FROM Contact.dbo.Contacts WHERE (Pkey = Contacts_PKey)), (SELECT Description FROM Common.dbo.LMain WHERE (PKey= DType)), (SELECT TaskName FROM Common.dbo.LTask WHERE (PKey = TaskType)) , StartTime, EndTime, SavedTime FROM dbo.TopicLog where StartTime > '7/9/09' ORDER BY StartTime
Instead
SELECT t.PKey, t.Billable, c.LastName, m.Description, lt.TaskName, t.StartTime, t.EndTime, t.SavedTime FROM dbo.TopicLog AS t inner join Contact.dbo.Contacts as c on c.Pkey = t.Contacts_PKey and t.StartTime > '7/9/09' inner join Common.dbo.LMain as m on m.PKey = t.DType inner join Common.dbo.LTask as lt on lt.PKey = t.TaskType ORDER BY t.StartTime
I prefer this type of syntax because it is much less confusing when writing or debugging, especially when there are many tables to be joined or something else happens (arguments to case, t-sql, self join, etc.)
But my question is that I get a performance hit by accessing the database this way.
I do not have enough data collected to measure the difference, but I will be at some point along the way.
I would like to know before proceeding. I would not want to come back later and redo everything to improve performance.
join sql-server tsql sql-server-2005
Lill lansey
source share