Why is it not generating error ?

  • 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.


    Kindest Regards,

    Syed
    Sr. SQL Server DBA

  • "SQLServerIsBadDatabase" is being taken as an alias for the table name.

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply