Sagar
Sagar

Reputation: 65

Sql server stored procedure

Some one please explain me how does this query works

SELECT 'WRITEBOARDCOMMENT' AS Type,
wbc.CommentText AS Content,
wb.WBId AS Id,
null AS ToDoListName,
null AS DueDate,
u.FirstName + ' ' + u.LastName AS ActivityBy,
wbc.[Date] as Date,
u.FirstName + ' ' + u.LastName as PartyName,
comp.CompanyId AS CompanyId,
comp.CompanyName AS CompanyName,
p.ProjectName,
p.ProjectId,
wbc.WBCmtId AS SubId,
p.ProjectStartPageId AS ProjectStartPageId  
FROM 
WriteboardComment AS wbc,
WriteBoardVersions AS wbv,
WriteBoard AS wb,
Project AS p,[user] AS u,
Company AS comp 
where 
wbc.wbversionid=wbv.wbversionsid and
wbv.WBId=wb.WBId and
wb.ProjectId=p.ProjectId and
p.ProjectId=@projectid and
wbc.CommentedBy=u.UserId and
p.PrimaryCompanyId=comp.CompanyId

What is the advantage of joining the tables like this.I found out this one in one project db code.

Upvotes: 0

Views: 100

Answers (2)

SQLMenace
SQLMenace

Reputation: 134923

There is no advantage, this is an old style join and you can easily shoot yourself in the foot when you mess up/leave out the WHERE clause and then you create a cartesian product/cross join by mistake

Upvotes: 1

Yves M.
Yves M.

Reputation: 3318

This used to be the old style of doing the joins. There is no advantage over the classical join version.

Upvotes: 0

Related Questions