Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Stupid Question about Brackets

Author  Topic 

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2008-10-28 : 09:25:23
I normally don't use brackets, but TOAD for SQL Server puts them in by default. Consequently, my code ends up looking like this:

SELECT dbo.somast.[fcompany],
dbo.somast.[fcustno],
dbo.somast.[forderdate],
sorels.fsono,
dbo.somast.[fsorev],
dbo.somast.[fcustpono],
sorels.identity_column,
sorels.fsono,


Is there some reason I should be using brackets around field names?

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-10-28 : 09:36:40
Brackets ar a way to delimit field/table/etc names that have spaces in them.
Toad adds them by default as does Query analyzer just in case.


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-28 : 09:51:25
It also helps to seperate system reserved names from table names or names starting with a number
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-28 : 11:31:40
Adding to afrika, it helps query engine to identify between reserved words and object/column names in cases where object/column name happens to be one among reserved words.
Go to Top of Page
   

- Advertisement -