Monday, March 26, 2012

query

Hi,

select * from test a where test.col1 = a;

The above query will not work and it will throw the error 'The column prefix 'test' does not match with a table name or alias name used in the query'. i.e if alias defined for a table, then the columns can be qualified only using using the alias. Is it true ? Is it true in all the places like "Group By', 'Order' , 'SELECT list' etc. Is that true in all databases, is it ANSI standard ?

Please advice,

Thanks,
MiraJhi

from BOL
"If an alias is assigned to a table, all explicit references to the table in the Transact-SQL statement must use the alias, not the table name."

No comments:

Post a Comment