views:

370

answers:

4

Hi,

I created a database with couple of tables and some table names are enclosed with square bracket: [table_name]

Does anyone qnow why this happen, and how to get rid of it?

Thanks!

+1  A: 

Are the tables in question MSSQL keywords? It's a common notation to put MSSQL object names in brackets. It's no big deal.

Stuart Branham
A: 

The square brackets are to indicate that the name represents an object and not a reserved word. By default SQL Server adds these to make sure the scripts it generates run correctly.

Kevin
+3  A: 

When you use SQL Server Management Studio to script out your objects it will enclose all names with square brackets.

They are only necessary when the name contains a space or a reserved word (such as [Name]).

Mitch Wheat
Question tagged with MSSQL - I don't think that SQL Server Management Studio will enter into the mix.
Bevan
@Bevan : it will. Even if you script your objects by hand without square brackets, if you use SSMS to output a script it will include them.
Mitch Wheat
A: 

Putting square brackets Sql Server allows you to use reserved words or phrases with spaces as identifiers. If your table containes any of these, it's normal behaviour.

eKek0