I created a database with couple of tables and some table names are enclosed with square bracket: [table_name]
Does anyone know why this happens, and how to get rid of it?
the brackets are special characters in sql server that are used to explicitly delimit information. they can be used in xml as per the article, they can also be used to specify meta names (column, table, etc.) that have spaces or other key words.
1) If you have SQL keyword, space or any other illegal characters then you need to use square brackets. 2) SQL server parse and compiler much more easy to validate and compile code. 3) code search tools easy to find table names or column names only.
To escape square brackets in LIKE you can use another square bracket to escape the original square bracket or use a custom escape character using the ESCAPE keyword in LIKE clause.
Syntax, Examples, and Text Parentheses are used in SQL to group parameters or arguments. They are required when entering a command (i.e. they must be typed exactly as they appear). { item1 item2 ... } Curly braces indicate groupings of identifiers, parameters, or arguments.
When you use SQL Server Management Studio to script out your objects it will enclose all names with square brackets.
They are only necessary when the name contains a space or a reserved word (such as [Name])
.
Are the tables in question MSSQL keywords? It's a common notation to put MSSQL object names in brackets. It's no big deal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With