IDENTIFIERS !!!

  • Hi All,

    I have recently answered some questions under 'QOD' section. I saw the below one and it looks strange for me.

    create table [VARRAY[]]]

    (

    eno int

    )

    When i execute the above code, the table got created. But when i run the same code in sybase, i got the below error message.

    Incorrect syntax near ']'.

    How sql server handles it internally ? what is the working mechanism behind this?

    karthik

  • karthikeyan-444867 (9/10/2011)


    Hi All,

    I have recently answered some questions under 'QOD' section. I saw the below one and it looks strange for me.

    create table [VARRAY[]]]

    (

    eno int

    )

    When i execute the above code, the table got created. But when i run the same code in sybase, i got the below error message.

    Incorrect syntax near ']'.

    How sql server handles it internally ? what is the working mechanism behind this?

    This is one of those things that may be difficult to GOOGLE even if you know what the name of the square brackets around the SQL objects is. 🙂

    In SQL Server, they known as "Delimited Identifiers" and can be found (in BOL 2005, anyway) under an index-lookup for "identifiers [SQL Server], delimited". Let's breakdown the table name in the example you gave by numbering the square brackets as pairs of brackets...

    [VARRAY[]]]

    1 2321

    Pair #1 - These are the actual "Delimited Identifiers". They're normally not used by most folks because they're normally not necessary. "Delimited Identifiers" are only needed if a table name has certain special characters in it such a spaces and other "reserved" characters. Because the table name in this example contains such reserved characters (brackets), Pair #1 is required to include such "reserved" characters in the table name.

    Pair #2 - These brackets are simply meant to become part of the table name which will look like VARRAY[] in the Object Explorer of SSMS.

    #3 - Obviously, this isn't a pair of brackets. Because brackets have a special meaning (Delimited Identifiers, in this case... there are others for use with LIKE) in SQL Server, Pair #2 above won't actually work as part of the naming unless you tell SQL Server that Pair #2 doesn't have special meaning. That's done simply by "escaping" the right bracket in Pair #2 with another right bracket which is what bracket #3 is doing.

    On how all of this works in SyBase, good luck... I've never worked with it but with what you've just learned and some of the terms associated with all of this, you should be able to figure it out using "help" in SyBase or mayby, now, even Google.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff (one of my most valuable sql teacher) ,

    Thanks a lot 🙂 I understand the concepts now.

    I appreciate you for spending some time for me to give a detailed answer for my questions.

    I will meet you in some other interesting post.

    karthik

  • karthikeyan-444867 (9/14/2011)


    Jeff (one of my most valuable sql teacher) ,

    Thanks a lot 🙂 I understand the concepts now.

    I appreciate you for spending some time for me to give a detailed answer for my questions.

    I will meet you in some other interesting post.

    Thanks for the feedback, Karthik... I appreciate it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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