Comments
4 comments
-
Hi @GregDodd
I'm not able to reproduce it with versionĀ 9.2.8.6358. Please upgrade and test again. -
I was on 9.2.6.6145, but it's still happening after updating to 9.2.8.6358. I can run the following on a new database (or tempdb):CREATE TABLE Product(ProductItemID INT PRIMARY KEY,ProductName VARCHAR(50),ProductCode VARCHAR(10),MainProductID INT)
Then write the following script:SELECT Product.ProductCode,MainProduct.ProductCodeFROM ProductINNER JOIN Product AS MainProductON MainProduct.ProductItemID = Product.MainProductIDORDER BY Product.ProductName
Then when I format it I get MainProduct.ProductName in the order by clause -
Hi @GregDodd
I've reproduced the issue! Thanks very much for your help.
It's logged asĀ SP-7229 in our internal bug tracking system. Please keep an eye on the release note for the fix! -
This issue has been closed, and the workaround is to alias both table sources.
Add comment
Please sign in to leave a comment.
e.g.:
When you format, it becomes:
The field names in the select statement correctly pick which table they are coming from (the aliased or non-aliased), but the order by clause always picks the aliased table.
If I alias both tables then it doesn't have a problem (Even if the alias is the same as the table name):