表列名称创建时空格自动格式化,为什么..?

时间:2021-08-02 16:29:24

I have create the column with name " Departure _Date " , but it is automatically changed into " [Departure _Date] "(Not in query using SQL Server Management studio). If i remove the empty space from the column name , there is no problem. Anyone can explain detailed..

我创建了名为“Departure _Date”的列,但它自动更改为“[Departure _Date]”(不使用SQL Server Management studio查询)。如果我从列名称中删除空格,则没有问题。有人可以解释详细..

1 个解决方案

#1


3  

Square brackets around column names are inferred. Even when you cannot see them they are always really there.

推断出列名周围的方括号。即使你看不到它们,它们也总是在那里。

When using spaces in column names and certain keywords it's necessary to use square brackets more frequently when referring to columns, including in table generation scripts and the design interface.

在列名和某些关键字中使用空格时,在引用列时需要更频繁地使用方括号,包括表生成脚本和设计界面。

SELECT Departure _Date FROM myTable

SELECT离开_Date FROM myTable

For example, without the square brackets, this SQL statement would be selecting the "Departure" field and returning it with an alias of "_Date".

例如,如果没有方括号,此SQL语句将选择“Departure”字段并使用别名“_Date”返回它。

Even when using the column name Departure_Date, the column could be referred to as either [Departure_Date] or Departure_Date in SQL statements.

即使使用列名Departure_Date,该列也可以在SQL语句中称为[Departure_Date]或Departure_Date。

#1


3  

Square brackets around column names are inferred. Even when you cannot see them they are always really there.

推断出列名周围的方括号。即使你看不到它们,它们也总是在那里。

When using spaces in column names and certain keywords it's necessary to use square brackets more frequently when referring to columns, including in table generation scripts and the design interface.

在列名和某些关键字中使用空格时,在引用列时需要更频繁地使用方括号,包括表生成脚本和设计界面。

SELECT Departure _Date FROM myTable

SELECT离开_Date FROM myTable

For example, without the square brackets, this SQL statement would be selecting the "Departure" field and returning it with an alias of "_Date".

例如,如果没有方括号,此SQL语句将选择“Departure”字段并使用别名“_Date”返回它。

Even when using the column name Departure_Date, the column could be referred to as either [Departure_Date] or Departure_Date in SQL statements.

即使使用列名Departure_Date,该列也可以在SQL语句中称为[Departure_Date]或Departure_Date。