Using SQL-DMO Multistrings

后续版本的 Microsoft SQL Server 将删除该功能。请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。

SQL Distributed Management Objects (SQL-DMO) multistrings are used in numerous parameters in SQL-DMO properties and methods. Using multistrings, a user can supply one or more delimited strings to the parameter, and SQL-DMO parses the input into multiple strings.

Database objects in instances of Microsoft SQL Server version 6.5 and earlier could not contain special characters such as spaces, commas, and semicolons. Therefore, these characters could be used interchangeably as string delimiter characters. For example, this multistring contains four separate strings:

S1 S2,S3;S4

However, database objects in instances of SQL Server version 7.0 and later can contain any characters valid in the underlying operating system, including spaces, commas, and semicolons. To accommodate this change, SQL-DMO multistring format uses left and right brackets ([]) as delimiters. The use of spaces, commas, and semicolons between bracketed strings is optional. For example these two multistrings, which contain four strings, are identical:

[S1] [S2] [S3] [S4]
[S1] [S2],[S3];[S4]

A right bracket is used as the escape character for a string that contains a right bracket. For example, the string "My]object" should be specified as:

[My]]object]

No escape character is required for a left bracket because SQL-DMO parses multistrings from left to right.

To maintain backward compatibility, the original multistring format is still supported if the string does not contain any spaces, commas, semicolons, or brackets. If an application uses the newer multistring format for one string, then the same format must be used for all strings in the multistring parameter.

SQL-DMO multistrings are used by these properties and methods:

Properties

DatabaseFileGroups Property

RpcList Property

DatabaseFiles Property

ShortMonths Property

Days Property

StandbyFiles Property

Devices Property

SuperSocketList Property

IndexedColumns Property

Tapes Property

Months Property

ViaRecognizedVendors Property

RelocateFiles Property

Methods

AddReplicatedColumns Method

Grant Method (StoredProcedure, UserDefinedFunction)

AttachDB Method

Grant Method (Table, View)

Deny Method (Database)

RemoveReplicatedColumns Method

Deny Method (StoredProcedure)

Revoke Method (Database)

Deny Method (Table, View)

Revoke Method (StoredProcedure)

Deny Method (UserDefinedFunction)

Revoke Method (Table, View)

GetRangeString Method

Revoke Method (UserDefinedFunction)

Grant Method (Database)

ValidateSubscriptions Method