Fully qualified column name

Posts   
 
    
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 01-Feb-2007 10:47:17   

Does anyone know why this works:

SELECT [MyXmlColumn].query('/root') FROM [MyDatabase].[dbo].[MyTable]

But this produces an error:

SELECT [MyDatabase].[dbo].[MyTable].[MyXmlColumn].query('/root') FROM [MyDatabase].[dbo].[MyTable] System.Data.SqlClient.SqlException: Invalid column name 'MyXmlColumn'.

This SQL is produced from a custom Expression I have written. I assume the this is just a SQL Server 2005 quirk. But base.ToQueryText() always seems to give this full qualified syntax.

Am I safe to intercept base.ToQueryText() just to give the column name or will that cause me other problems in LLB? or is there a reason for all this I am missing?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 01-Feb-2007 10:49:29   

If just the column name works, you have no option but to return the column name and not the rest. Still odd though...

Frans Bouma | Lead developer LLBLGen Pro
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 05-Feb-2007 11:31:46   

FYI

I got this answer from MS. http://forums.asp.net/thread/1557041.aspx

Kevin wrote:

Hi Simon,

Actually, this is by design. When we use a XQuery on a column, we can only use the Column name in SELECT.


Sincerely, Kevin Yu Microsoft Online Community Support