Home >Database >Mysql Tutorial >Why Are Square Brackets Used in MS-SQL Table Column Names?
Square Brackets in MS-SQL Table Designer: Understanding Their Significance
In the context of MS-SQL table design, square brackets [] play a crucial role in identifying columns. While exploring a copy of an existing database, you may encounter column names enclosed in square brackets. This has prompted the question about the purpose and implications of such notation.
Purpose of Square Brackets in MS-SQL
Square brackets serve the following purposes in MS-SQL:
Example:
As per the Microsoft Developer Network (MSDN), delimited identifiers are enclosed in double quotation marks (") or square brackets ([]).
SELECT * FROM [TableX] --Delimiter is optional. WHERE [KeyCol] = 124 --Delimiter is optional.
Identifiers containing special characters or reserved keywords must be delimited in Transact-SQL statements.
SELECT * FROM [My Table] --Identifier contains a space and uses a reserved keyword. WHERE [order] = 10 --Identifier is a reserved keyword.
Additional Information:
The above is the detailed content of Why Are Square Brackets Used in MS-SQL Table Column Names?. For more information, please follow other related articles on the PHP Chinese website!