I would like to know what special characters are allowed to be used in column name in T-SQL, MSSQL. So I know I can use letters and numbers, but are the other characters that are available without using brackets [] to refer to this column?
我想知道在T-SQL,MSSQL中允许在列名中使用哪些特殊字符。所以我知道我可以使用字母和数字,但其他字符是否可用,而不使用方括号[]来引用此列?
1 个解决方案
#1
from MSDN:
The first character must be one of the following:
第一个字符必须是以下之一:
- A letter as defined by the Unicode Standard 3.2. The Unicode definition of letters includes Latin characters from a through z, from A through Z, and also letter characters from other languages.
- The underscore (_), at sign (@), or number sign (#).
Unicode标准3.2定义的字母。字母的Unicode定义包括从a到z,从A到Z的拉丁字符,以及来自其他语言的字母字符。
下划线(_),符号(@)或数字符号(#)。
Subsequent characters can include the following:
后续字符可包括以下内容:
- Letters as defined in the Unicode Standard 3.2.
- Decimal numbers from either Basic Latin or other national scripts.
- The at sign, dollar sign ($), number sign, or underscore.
Unicode标准3.2中定义的字母。
来自Basic Latin或其他国家脚本的十进制数字。
at符号,美元符号($),数字符号或下划线。
The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.
标识符不能是Transact-SQL保留字。 SQL Server保留保留字的大写和小写版本。
Embedded spaces or special characters are not allowed.
不允许嵌入空格或特殊字符。
Supplementary characters are not allowed.
不允许使用补充字符。
edit
refering to NinthSense: the specs also says:
参考NinthSense:规格还说:
Certain symbols at the beginning of an identifier have special meaning in SQL Server. A regular identifier that starts with the at sign always denotes a local variable or parameter and cannot be used as the name of any other type of object.
标识符开头的某些符号在SQL Server中具有特殊含义。以at符号开头的常规标识符始终表示局部变量或参数,不能用作任何其他类型对象的名称。
and this statement can be executed without errors:
并且此语句可以无错误地执行:
create table #t (
#oid int ,
äß int,
ßdid varchar(10),
_data varchar(10)
)
#1
from MSDN:
The first character must be one of the following:
第一个字符必须是以下之一:
- A letter as defined by the Unicode Standard 3.2. The Unicode definition of letters includes Latin characters from a through z, from A through Z, and also letter characters from other languages.
- The underscore (_), at sign (@), or number sign (#).
Unicode标准3.2定义的字母。字母的Unicode定义包括从a到z,从A到Z的拉丁字符,以及来自其他语言的字母字符。
下划线(_),符号(@)或数字符号(#)。
Subsequent characters can include the following:
后续字符可包括以下内容:
- Letters as defined in the Unicode Standard 3.2.
- Decimal numbers from either Basic Latin or other national scripts.
- The at sign, dollar sign ($), number sign, or underscore.
Unicode标准3.2中定义的字母。
来自Basic Latin或其他国家脚本的十进制数字。
at符号,美元符号($),数字符号或下划线。
The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.
标识符不能是Transact-SQL保留字。 SQL Server保留保留字的大写和小写版本。
Embedded spaces or special characters are not allowed.
不允许嵌入空格或特殊字符。
Supplementary characters are not allowed.
不允许使用补充字符。
edit
refering to NinthSense: the specs also says:
参考NinthSense:规格还说:
Certain symbols at the beginning of an identifier have special meaning in SQL Server. A regular identifier that starts with the at sign always denotes a local variable or parameter and cannot be used as the name of any other type of object.
标识符开头的某些符号在SQL Server中具有特殊含义。以at符号开头的常规标识符始终表示局部变量或参数,不能用作任何其他类型对象的名称。
and this statement can be executed without errors:
并且此语句可以无错误地执行:
create table #t (
#oid int ,
äß int,
ßdid varchar(10),
_data varchar(10)
)