x

disable square braces when generating scripts from SSMS

How do I disable square braces when generating scripts from SSMS?

more ▼

asked Oct 12, 2009 at 10:27 AM in Default

binoj gravatar image

binoj
32 1 1 1

(comments are locked)
10|1200 characters needed characters left

7 answers: sort newest

While it might bother you, it's a good practice. It ensures that any strange characters in your objects, spaces, etc., don't cause issues when you run the script. You might think you'll never do this, but with a version upgrade, that table you created in a previous version might not have a keyword for a name.

more ▼

answered Oct 12, 2009 at 10:53 AM

Steve Jones - Editor gravatar image

Steve Jones - Editor ♦♦
5.1k 78 79 82

Agreed. Probably best just to leave them in. However, Darren provided the way to remove them all if you really want them removed.
Jun 01, 2010 at 03:33 PM TimothyAWiseman
(comments are locked)
10|1200 characters needed characters left
Been using SQL Server since Sybase 4.2 and this drives me NUTS! It is NOT good practice to use brackets. What is good practice is NOT USING RESERVED WORDS as object names. Bracketing object names is a quick way to violate all sorts of bad practices, like using punctuation in your name. The genesis of brackets had to do with cross platform development and conversions. You can always add brackets to your code if you need to and SQL is smart enough to know the difference contextually 95% of the time anyway. When scripting, SSMS should identify reserved words that are being used as objects and bracket ONLY those. This would make it more obvious that you are using a reserved word. Please change this.
more ▼

answered Dec 05, 2012 at 12:09 AM

kferrell gravatar image

kferrell
0

(comments are locked)
10|1200 characters needed characters left

RegEx Find and Replace. Find "[[]]" Replace ""

more ▼

answered Jun 01, 2010 at 09:52 AM

Darren 1 gravatar image

Darren 1
11

That's a bit of a sub-standard approach, as it would blanket remove all square braces, even where they are required for non-natural identifiers.
Jun 01, 2010 at 10:24 AM Matt Whitfield ♦♦
@Matt, I agree with you, but if the original poster want to disable them then the poster presumably knows that they are not necessary. This is the closest thing to a direct solution to the original question I saw.
Jun 01, 2010 at 03:33 PM TimothyAWiseman
(comments are locked)
10|1200 characters needed characters left

Hate It. I believe there should be something like the VB "Option Explicit" which would explicitly disable any reserved words from being a DB object.

more ▼

answered Oct 12, 2009 at 12:54 PM

dvroman gravatar image

dvroman
1.1k 2 2

(comments are locked)
10|1200 characters needed characters left

I think it is a nuisance, and I agree wholehartedly with the questioner that there ought to be a way to kick it out. Although I have to admit that I occasionally use them when I accidentally use a reserved word, I don't see why one should not be able to enforce a 'standards' mode in a database, and do without the square braces. To illustrate the way that one can abuse all guidelines for sensible programming by means of square braces, see my blog post. Evil Code

more ▼

answered Oct 12, 2009 at 11:04 AM

Phil Factor gravatar image

Phil Factor
3.9k 8 9 16

Have to say I agree with you sir. I especially like the way that you can include square brackets in a name by double quoting - vb style. For example, a column called [[[]]] would appear in SQL text as [[[]]]]]. Neat. (!)
Oct 12, 2009 at 11:55 AM Matt Whitfield ♦♦
Prefer not to use them either, so annoying. Have a look at the following feature request, I added a comment to broaden its context a little: https://connect.microsoft.com/SQLServer/feedback/details/540306/ssms-improvements-required-for-dragging-columns-from-object-explorer
May 15, 2013 at 11:36 AM Valentino Vranken
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x346
x127
x69
x15
x1

asked: Oct 12, 2009 at 10:27 AM

Seen: 4891 times

Last Updated: May 15, 2013 at 11:36 AM