Sunday, February 12, 2012

Brackets appear in column name

I am using Enterprise Manager to create database tables. In the table design view I am trying to create a column called, section. After typing, section, Enterprise Manager automatically puts brackets around the name, ex. [section]. When I view the table by returning all rows the brackets are gone. However, when I go back to desing view the brackets are there. Why is this happening and what affect does it have on my database?

Thanks,

Matt

That is 'normal' and expected behavior when your table or column names contain spaces or other 'invalid' characters.

SQL Server, unlike Access you may have been using, does not allow the use of spaces in object (tables, columns, etc.) names. You will always have to use those 'pesky' square brackets when you write any SQL code specifying the improperly named items.

Other than the extra work always having to use the square brackets when writing code, there is no discernable impact on the database. The database assigns an 'ObjectID' to all tables, columns, etc., and internally, it uses the ObjectID.

|||

Arnie,

The column name I am trying to use is, section, with no spaces but Enterprise Manager is automatically putting the brackets on. Any ideas?

Thanks,

Matt

|||

I should have included that square brackets are also included around 'reserved words' when used as object names.

You may wish to examine the 'reserved word' list in Books Online, and then avoid using any reserved words in your object names.

As I indicated before, if EM adds the square brackets, you will also be required to also use square brackets (or double quotes) when referring to those improperly named objects.

|||

Arnie,

I found the word, section, in the Books Online. It is an ODBC reserved word. Thanks for the help,

Matt

|||

Matt,

If that information helped you solve your issue, please mark the post as helpful.

Thanks

No comments:

Post a Comment