Square Brackets in MS-SQL Table Designer
In MS-SQL's Table Designer, square brackets ([]) are used to enclose column names. While this may not appear significant, it holds important implications.
Purpose of Square Brackets
Square brackets delimit identifiers, specifically column names. This demarcation becomes necessary when column names conflict with reserved keywords or include special characters like spaces or hyphens.
Reserved Keywords and Special Characters
Reserved keywords are terms designated by MS-SQL with specific meanings. If a column name matches a reserved keyword, it must be enclosed in square brackets to avoid conflicts. Similarly, when a column name contains special characters, brackets are required to prevent ambiguity.
Optional Usage
Delimiting column names using brackets is optional even when not strictly necessary. Some users prefer to use brackets consistently for better readability or to highlight specific columns.
MSDN Explanation
MSDN (Microsoft Developer Network) explains that delimited identifiers using double quotation marks (") or square brackets are an optional practice. Identifiers that follow the standard naming rules may or may not be delimited. However, delimitation becomes essential for identifiers that do not meet these rules.
The above is the detailed content of When Should I Use Square Brackets in MS-SQL Column Names?. For more information, please follow other related articles on the PHP Chinese website!