SQL Server 实例名称的最大长度?
我需要知道以下版本的 SQL Server 实例名称的最大字符长度(如果它们之间存在差异)。
- SQL Server 2000
- SQL Server 2005
- SQL Server 2008
- SQL Server 2008 R2
(我正在研究一个通过 DMO/SMO API 与 SQL Server 通信并需要验证用户输入的应用程序。)
经过多次 Google 和 BOL 搜索后,我无法找到明确的答案。我发现了论坛问题和回复(在其他较小的网站上),但这些回复中的值范围为 16 到 128 个字符,并且没有提供支持文档或链接。
看起来这应该是一个很容易找到的东西,但它却让我困惑。任何帮助将不胜感激。
I need to know the maximum character length for the name of an instance of a SQL Server for the following versions (if there is a difference between them.)
- SQL Server 2000
- SQL Server 2005
- SQL Server 2008
- SQL Server 2008 R2
(I am working on an application that will communicate with SQL Server via the DMO/SMO APIs and need to validate user input.)
After much Googling and BOL searching I have not been able to find a definitive answer. I have found forum questions and responses (on other, lesser sites) but the values in those responses have ranged from 16 to 128 characters and none provided supporting documentation or links.
It seems that this should be an easy find but it has eluded me. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SQL Server 的实例名称限制为 16 个字符
http: //msdn.microsoft.com/en-us/library/ms143531(v=SQL.105).aspx
它没有在线列出 SQL Server 2000,而是查看我为 SQL Server 2000 安装的 BOL它也限制为 16 个字符。
编辑
使用此屏幕添加和维护 Microsoft® SQL 实例Server™ 2000。
选项
默认
选择此选项后,将安装 SQL Server 2000 的默认实例。单击“下一步”继续安装过程。
清除后,您可以安装或维护 SQL Server 2000 的命名实例。
注意 如果未启用此复选框,则安装程序已在此计算机上检测到 SQL Server 的默认实例。默认实例可以是 SQL Server 6.5、SQL Server 7.0 版的安装,也可以是已安装的 SQL Server 2000 的默认实例。任一时间只能安装一个 SQL Server(任何版本)作为默认实例。有关详细信息,请参阅 SQL Server 的多个实例。
实例名称
输入新实例名称或要维护的实例的名称。查看并遵循实例名称的规则。
重要 建议实例名称少于 10 个字符。实例名称可以出现在各种SQL Server和系统工具的用户界面中;较短的名称更具可读性。
**实例命名规则 **
实例名称不区分大小写。
实例名称不能是术语 Default 或 MSSQLServer。
实例名称必须遵循 SQL Server 标识符规则,并且不能是保留关键字。
实例名称限制为 16 个字符。
实例名称中的第一个字符必须是字母、与号 (&)、下划线 (_) 或数字符号 (#)。可接受的字母是 Unicode 标准 2.0 定义的字母,其中包括拉丁字符 az 和 AZ,以及其他语言的字母字符。
后续字符可以是:
Unicode 标准 2.0 中定义的字母。
来自基本拉丁语或其他国家文字的十进制数字。
美元符号 ($)、数字符号 (#) 或下划线 (_)。
实例名称中不允许嵌入空格或特殊字符。反斜杠 ()、逗号 (,)、冒号 (:) 或 at 符号 (@) 都不是。
警告 在 SQL Server 2000 的实例名称中只能使用当前 Microsoft Windows® 代码页中有效的字符。如果使用当前代码页不支持的 Unicode 字符,则会发生错误。
Instance names for SQL Server are limited to 16 characters
http://msdn.microsoft.com/en-us/library/ms143531(v=SQL.105).aspx
It doesn't list SQL Server 2000 online but looking at the BOL that I have installed for SQL Server 2000 it is also limited to 16 characters.
EDIT
Use this screen to add and maintain instances of Microsoft® SQL Server™ 2000.
Options
Default
When selected, a default instance of SQL Server 2000 is installed. Click Next to proceed with the install process.
When cleared, you can install or maintain a named instance of SQL Server 2000.
Note If this check box is not enabled, Setup has detected a default instance of SQL Server on this computer. The default instance could be an installation of SQL Server 6.5, SQL Server version 7.0, or it could be the default instance of SQL Server 2000, already installed. Only one installation of SQL Server, any version, can be the default instance at any one time. For more information, see Multiple Instances of SQL Server.
Instance Name
Enter a new instance name, or the name of the instance to maintain. Review and follow the rules for instance names.
Important It is recommended that instance names be kept to less than 10 characters. Instance names can appear in the user interface of various SQL Server and system tools; shorter names are more readable.
**Instance Naming Rules **
An instance name is not case-sensitive.
An instance name cannot be the terms Default or MSSQLServer.
Instance names must follow the rules for SQL Server identifiers and cannot be reserved keywords.
Instance names are limited to 16 characters.
The first character in the instance name must be a letter, an ampersand (&), an underscore (_), or a number sign (#). Acceptable letters are those defined by the Unicode Standard 2.0, which includes Latin characters a-z and A-Z, in addition to letter characters from other languages.
Subsequent characters can be:
Letters as defined in the Unicode Standard 2.0.
Decimal numbers from either Basic Latin or other national scripts.
The dollar sign ($), a number sign (#), or an underscore (_).
Embedded spaces or special characters are not allowed in instance names. Neither is the backslash (), a comma (,), a colon (:), or the at sign (@).
Warning Only characters that are valid in the current Microsoft Windows® code page can be used in instance names in SQL Server 2000. If a Unicode character not supported under the current code page is used, an error occurs.
我在 SQL 2008 R2 中的经验是:
Windows Server 2008 R2 NetBIOS 有 15 个字符的限制。
如果您想要一个超出此范围的 SQL Server 默认实例名称 (@@SERVERNAME),那么您必须执行以下操作:
sp_dropserver 'oldname'
去
sp_addserver 'newname_greater_than_15_characters','本地'
go
重新启动MSSQLService,您的新名称就会生效。 Sysname 是与函数和系统存储过程一起使用的数据类型。
My experience in SQL 2008 R2 is:
Windows Server 2008 R2 NetBIOS has a 15 character limit.
If you want a SQL Server default instance name beyond this (@@SERVERNAME) then you will have to do the following:
sp_dropserver 'oldname'
go
sp_addserver 'newname_greater_than_15_characters','local'
go
Restart the MSSQLService and your new name takes effect. Sysname is the datatype in play with the function and system stored procedures.
我见过的唯一字符限制是 SQL Server 2012,并且正如其他人所说,该限制似乎是 16 个。我有 2008 和 2008 R2 实例,其中名称似乎没有受到限制(例如 MSRS10.MSSQLSERVER_2008),但这可能只是因为我没有尝试超过 23 或 24 个字符的任何内容。很抱歉,这没有提供文档中的信息,但我希望它有帮助。
The only instances where I've seen a character limit are for the SQL Server 2012, and that limit appears to be 16 as others have said. I have 2008 and 2008 R2 instances where the name doesn't seem to have been limited (e.g. MSRS10.MSSQLSERVER_2008), but that could just be that I didn't try for anything longer than 23 or 24 characters. I'm sorry this doesn't provide information from docs, but I hope it's helpful.
杰尔:
sp_dropserver 'oldname' go sp_addserver 'newname_greater_than_15_characters','local' go
我相信这是服务器名称而不是实例名称。
jl:
sp_dropserver 'oldname' go sp_addserver 'newname_greater_than_15_characters','local' go
I believe this is for the server name and not the instance name.