>> What are these brackets for, and when should they be used?
In my opinion, the brackets make the code harder to read. Their purpose is to identify objects within the database. Anything within the brackets should be an object name. Obviously, the brackets are optional.
Brackets are necessary when you have an object name that is the same as a reserved word. When I say object, you should think: Database Name, Table Name, Column Name, Stored Procedure Name, FunctionName, etc...
For example, suppose you want to name a column
Select...
Create Table Table(Select Int)
[tt][red]Server: Msg 156, Level 15, State 1, Line 1[/red]
Incorrect syntax near the keyword 'Select'.[/tt]
You can use the brackets to get around this error.
Code:
Create Table [Table]([Select] Int)
Select [Select] From [Table]
When should they be used? In my opinion... Never. As I already explained, they MUST be used when you have an object name that is a reserved word. Simply put, you should NOT name your objects the same as reserved words. If you follow this advice, then you will never need to use brackets.
Make sense?
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom