September 13, 2006 at 4:17 am
When running this mistyped query
'select name, dbid sid, mode from master.dbo.sysdatabases order by dbid'
from Management Studio against a SQL Server 2000 instance, I expect an error. Instead it happily executes the query, displaying and ordering by the sid column.
Is this a bug or feature? Is it naive of me to expect the parser to raise a flag here? Am I too picky?
September 13, 2006 at 4:29 am
OK, my bad.
I have always used the syntax colname AS newcolname, believing it was required, but as it turns out, it is optional.
September 13, 2006 at 6:39 am
Like you said it was not ordering by sid but was ordering by dbid but was dsiplaying dbid as sid (as is optional)
September 13, 2006 at 5:00 pm
There isn't an setting anywhere to make it non-optional is there? Thus to alias a column you would have to write alias = column or column as alias.
September 13, 2006 at 6:36 pm
you can put a quote on the alias name eg. select dbid 'sid' from sysdatabases
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply