T-SQL列名称中允许使用哪些特殊字符? [英] What special characters are allowed in T-SQL column name?

查看:570
本文介绍了T-SQL列名称中允许使用哪些特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在T-SQL,MSSQL的列名中允许使用哪些特殊字符.因此,我知道我可以使用字母和数字,但是不使用方括号[]来引用此列的其他字符是否可用?

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?

推荐答案

来自 MSDN :

第一个字符必须是以下字符之一:

The first character must be one of the following:

  • Unicode标准3.2定义的字母.字母的Unicode定义包括从a到z,从A到Z的拉丁字符,以及其他语言的字母字符.
  • 下划线(_),符号(@)或数字符号(#).

后续字符可以包括以下内容:

Subsequent characters can include the following:

  • Unicode标准3.2中定义的字母.
  • 基本拉丁文字或其他国家文字的十进制数字.
  • at符号,美元符号($),数字符号或下划线.

标识符不得为Transact-SQL保留字. SQL Server保留保留字的大写和小写版本.

The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.

不允许包含空格或特殊字符.

Embedded spaces or special characters are not allowed.

不允许使用补充字符.

编辑

指的是NinthSense:规范还说:

refering to NinthSense: the specs also says:

在标识符开头的某些符号在SQL Server中具有特殊含义.以at符号开头的常规标识符始终表示局部变量或参数,不能用作任何其他类型的对象的名称.

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.

并且此语句可以正确执行:

and this statement can be executed without errors:

create table #t (
  #oid int ,
  äß int,
  ßdid varchar(10),
  _data varchar(10)
)

这篇关于T-SQL列名称中允许使用哪些特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆