SSMS Generate Script Replaces Quoted Identifiers with Square Brackets

  • I've been coming to this site for years. I've never registered, and I almost always find the answer to my questions. But I am stumped. I freely accept your LRN2SRCH responses if this has been asked and answered a dozen times already...

    Trying to get less behind the curve, I'm bringing up a database running on compatibility 100 to 140. I started modifying some problem procedures and decided to use quoted identifiers on names, because the schema I have inherited has some fantastic column names like 'user' and 'timestamp'.

    However, when I script them back out in SSMS, my quoted identifiers have been replace with the square brackets. I cannot find anywhere in the options to change this behavior. Please send help. Thank you.

  • It's the nature of the beast and, to be honest, the brackets are the preferred method (in SQL Server, anyway) for using reserved words and object names that contain spaces, dashes, etc.  The brackets are the same thing as quoted identifiers and is actually the default used by the QUOTENAME() function.

    And, no... no "LRN2SRCH responses" for this one.  This isn't an easy find unless you already know the answer, which would mean you know what to search for.  Heh... like I tell people, how can you find the correct spelling of a word in a dictionary if you have no clue as to how the word is spelled?

    --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)

  • There is no option to disallow this. There is a feedback item to add this, but so far. MS has not implemented this option.

     

  • Thanks for the quick answers. I guess I'll stick with the square brackets. Glad I didn't change too many procedures first!

  • Andy Mallon has a procedure to remove them.

    https://am2.co/2018/07/removing-square-brackets-from-generated-ssms-scripts/

     

  • Steve Jones - SSC Editor wrote:

    Andy Mallon has a procedure to remove them.

    https://am2.co/2018/07/removing-square-brackets-from-generated-ssms-scripts/

    It's no longer needed if you have the later versions of SSMS.  It's actually a setting now and, IIRC, it also leaves essential brackets in place..

    My apologies.  This is wrong.  It's only for the click'n'drag functionality of the Object Explorer

    • This reply was modified 3 years, 8 months ago by  Jeff Moden.

    --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)

  • I know it's an option in SQL Prompt... but... I do not think the inclusion/exclusion of quoted identifiers is a configurable scripting setting in SSMS.

  • Jason A. Long wrote:

    I know it's an option in SQL Prompt... but... I do not think the inclusion/exclusion of quoted identifiers is a configurable scripting setting in SSMS.

    Ah... my apologies.  It's only for the click'n'drag functionality in the Object Explorer.  I fixed my prior post on it, as well.,

    Ok... more coffee.

    --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 8 posts - 1 through 7 (of 7 total)

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