Originally posted by puT3
In general, using [] to surround object names in SQL is not necessary. However there are situations where, without the [] specifically indicating that the contents refer to an object (Field; Table; Control from a form; Query; Database even sometimes) interpreting the SQL could be ambiguous (Remember we discussed clarity and ambiguity in communication earlier, well it applies even more specifically to computers). Well, if the SQL engine, or interpreter, is unable to understand what is meant, then it will not execute the SQL (at least not correctly).
Examples of possible ambiguity are reserved words (Date; For; SELECT; etc), as well as object names with embedded spaces (SQL uses any white space as a separator). If any of these are used as object names, then the SQL engine would not know whether the word referred to your object or the inbuilt item. Surrounding them in [] makes it clear exactly what is intended.
As far as posting goes, and READABILITY of the SQL, I often use them where they are not strictly required by the SQL engine, to make the context clearer and easier to read. Whenever you see something in the [] you KNOW it's an object. I don't use them so much within my own SQL, but for clarity on the forums I do.
PS. @Joe P.
Sorry, didn't catch your post until after I'd already posted this one. Thanks for jumping in anyway. All contributions appreciated :)
Comment