April 23, 2008 at 9:52 am
Can any one help or explain why SQL Server does not produce error in SELECT statement.
select * from Table_Name SQLServerIsBadDatabase
dbcc inputbuffer(@@spid)
GO
select * from Table_Name SQLServerIsBadDatabase
WHERE ColumnXYZ = AnyValue
dbcc inputbuffer(@@spid)
GO
The above statement should generate an error but it does not, you can replace "SQLServerIsBadDatabase" with any thing as long as it is one word (no spaces) and SELECT statement will execute correctly. This will work on 2000 and 2005 both.
I understand that it is taking it as table hint and most probably ignoring it, but is it some kind of standard ? even MySQL database server does not produce error.
April 23, 2008 at 10:39 am
"SQLServerIsBadDatabase" is being taken as an alias for the table name.
April 23, 2008 at 12:25 pm
The keyword AS for specifying an alias is optional. These are equivalent statements
SELECT 1 AS This_Is_A_Column_Alias FROM SomeTable AS This_Is_A_Table_Alias
SELECT 1 This_Is_A_Column_Alias FROM SomeTable This_Is_A_Table_Alias
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply