How do I disable square braces when generating scripts from SSMS?
How do I disable square braces when generating scripts from SSMS?
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 now have a keyword for a name.
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
RegEx Find and Replace. Find "[\[\]]" Replace ""
@kferrell It really sucks that when I right-click and choose "Select top 1000 rows" option, it brings a new tab with the SELECT statement with square brackets and all, but leave the selected database as "master". So when I go ahead and write another query on the same tab I HAVE TO a) explicitly specify the db name or b) choose my database from the dropdown menu. Same for "Edit Query Text" option under Activity Monitor. Like come on SSMS, you know which db was it run under, so auto select the db for that query when you open it.
Maybe off-topic but I think these can be grouped under "annoying issues of SSMS".
Our IT use multiple instances on the same server, so server\SQL1, etc. If I don't use square brackets, then everything fails. User-schema objects (Domain\LoginID) also fail. Square brackets don't interfere with anything when your objects are well-formed names, despite Phil's gnarly examples, I think it's a very low-risk thing to use and solves more problems than it creates.
4 People are following this question.