Name ,Type Words turns blue color in query window

  • Blinking RED.

    OUCH !

    Merry Christmas.

  • I heard name is a reserved MDX word (http://msdn.microsoft.com/en-us/library/ms145629.aspx), and "Type" is used in permission statements (GRANT) - http://msdn.microsoft.com/en-us/library/ms174346.aspx

  • TYPE is also used in some FOR XML statements.

    UID was ubiquitous in most of the system views in 2000 (sysobjects, sysusers, permisssions, etc....), is a keyword in ado connection strings (like what you might set up in OPENROWSET), and is an implicit rowID in xml data sets (although I don't think in 2005). So - common enough to possibly "pre-reserve".

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Steve Jones - Editor (12/23/2008)


    I heard name is a reserved MDX word (http://msdn.microsoft.com/en-us/library/ms145629.aspx), and "Type" is used in permission statements (GRANT) - http://msdn.microsoft.com/en-us/library/ms174346.aspx%5B/quote%5D

    Which is my earlier point. It is nice that they highlight ALL of the keywords that they have ever used in the entire product offering but since the colorization is not filtered by context, you get a ton of "false positives" depending upon what you are typing.

    So if I'm entering a standard SQL query, I shouldn't be bothered by reserved words in MDX. Which BTW, is not part of any SQL standard.

    Numerous tools (e.g., TOAD, Embacadero, etc.) and text editors also have syntax colorization, including keywords. Some of these applications allow you to modify the keyword/reserved word list.

    Therefore, use the colorization as a quide tempered by the context of what you are typing.


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

  • By the way - here's an example of TYPE being used as a T-SQL keyword:

    select * from MyTable

    where MyID=1234

    for XML path('testing'), TYPE

    Not sure why that didn't make the reserved list.

    Considering you can mix DCL and DML and MDX in scripts, why wouldn't you want them highlighted as possible sticking points? It would be nice if the colorizer were a tad bit smarter, but I do see why it's done the way it is.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Matt Miller (12/23/2008)


    By the way - here's an example of TYPE being used as a T-SQL keyword:

    select * from MyTable

    where MyID=1234

    for XML path('testing'), TYPE

    Not sure why that didn't make the reserved list.

    Considering you can mix DCL and DML and MDX in scripts, why wouldn't you want them highlighted as possible sticking points? It would be nice if the colorizer were a tad bit smarter, but I do see why it's done the way it is.

    Yes, and I understand what is happening. BTW, I've written queries that return XML.

    So the following query shows the [keyword] "type" being returned as a column name as well as the use of "type" in proper syntax. Both are highlighted but only one is really a "keyword".

    [font="Courier New"]SELECT

    u.user_id AS UserID,

    u.type AS Type

    FROM users u

    FOR XML PATH('testing'), TYPE[/font]

    So the take-away is to not panic and feel that you have to change your code, query, whatever when you see terms highlighted as "keywords" within the SSMS editor.

    P.S. I actually use an external editor to write all of my SQL Server code (table DDL, sprocs, UDFs, etc.) and only use SSMS to validate it and/or perform unit tests. The editor has syntax colorization with a unionized set of keywords that cover both Oracle and SQL Server with the colorization only being used as a "guide". Since we have all of our code as separate files within our source code control system, and the editor is invoked directly from the source code control menu, I'm not really monitoring the keyword colorization of SSMS.


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

  • JohnG (12/23/2008)


    So the take-away is to not panic and feel that you have to change your code, query, whatever when you see terms highlighted as "keywords" within the SSMS editor.

    Agreed. It earns a second glance but not much more.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 7 posts - 16 through 21 (of 21 total)

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