Advertisement

04.22.2008 at 04:58PM PDT, ID: 23345051
[x]
Attachment Details

Invalid Column Name when using Alias in Order By clause

Asked by CRCInfosys in SQL Server 2005, MS SQL Server, SQL Query Syntax

Tags: Microsoft, SQL Server Management Studio, 9.00.1399.00

For some reason, my query is generating an "invalid column name" error on only one server out of many.  
I do not want to post the entire query as it is too large but this query here sums up where I'm getting at:

SELECT A.COL1, A.COL2 AS WORD, B.COL4
FROM A
INNER JOIN B ON B.COL1 = A.COL1
ORDER BY A.WORD

I know that the error is being generated by the use of an Alias in the Order By clause paired with the Table Name.  It runs fine if I either remove the table name or if I use the original column name.  However, as it is,  this type of query runs fine on most other servers.  I know it is not the version of the SQL Management Studio because I have tried it on a server with the same version and it executes just fine.

Is there a setting somewhere in the SQL Server that would prevent the pairing of
<table name>.<column alias> in the order by clause?Start Free Trial
[+][-]04.22.2008 at 05:05PM PDT, ID: 21416697

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 05:34PM PDT, ID: 21416805

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 05:39PM PDT, ID: 21416829

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 07:13PM PDT, ID: 21417275

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, MS SQL Server, SQL Query Syntax
Tags: Microsoft, SQL Server Management Studio, 9.00.1399.00
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 5
Solution Grade: A
 
 
[+][-]04.22.2008 at 07:34PM PDT, ID: 21417372

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 08:15PM PDT, ID: 21417523

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.22.2008 at 08:17PM PDT, ID: 21417529

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 12:10AM PDT, ID: 21418311

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 10:57AM PDT, ID: 21423447

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628