Toad World® Forums

Bug in QB when ordering custom aliases


#1

Ok. This I think should raise a ticket.

I have this code …

SELECT cs.StudentID,
cs.StudentName AS [Full Name],
tc.TradeCatName AS Category,
sp.TradeName AS Trade
FROM (AimsDevelopment.dbo.vwStudentProgramCurrent sp
INNER JOIN AimsDevelopment.dbo.tblTradeCategories tc
ON (sp.TradeCatID = tc.TradeCatID))
INNER JOIN AimsDevelopment.dbo.vwCurrentStudents cs
ON (cs.StudentID = sp.StudentID)

And I have the [Full Name] alias above created when I added that alias in the diagram section.

Now if I want to ORDER BY that field, this is what the QB does …

SELECT cs.StudentID,
cs.StudentName AS [Full Name],
tc.TradeCatName AS Category,
sp.TradeName AS Trade
FROM (AimsDevelopment.dbo.vwStudentProgramCurrent sp
INNER JOIN AimsDevelopment.dbo.tblTradeCategories tc
ON (sp.TradeCatID = tc.TradeCatID))
INNER JOIN AimsDevelopment.dbo.vwCurrentStudents cs
ON (cs.StudentID = sp.StudentID)
ORDER BY Full
Name
ASC

Obviously the ORDER BY created by the QB is syntactically incorrect.

It should have done this …

SELECT cs.StudentID,
cs.StudentName AS [Full Name],
tc.TradeCatName AS Category,
sp.TradeName AS Trade
FROM (AimsDevelopment.dbo.vwStudentProgramCurrent sp
INNER JOIN AimsDevelopment.dbo.tblTradeCategories tc
ON (sp.TradeCatID = tc.TradeCatID))
INNER JOIN AimsDevelopment.dbo.vwCurrentStudents cs
ON (cs.StudentID = sp.StudentID)
ORDER BY [Full Name] ASC

Thanks


#2

The issue has been fixed some time ago and you can download a beta to verify it.
What version of Toad do you use?

Aleksey


#3

Hi Alek,

Toad for SQL Server 5.8.0.831

So what version of TOAD SQL has this been fixed in? I would like to give it another try.

Thank you


#4

Please try current 6.0 Beta
http://toadforsqlserver.com/beta.jspa