次の方法で共有


Defaults Collection

この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。

The Defaults collection contains Default objects that reference Microsoft SQL Server defaults.

現在のオブジェクトを表す SQL-DMO オブジェクト モデル

Properties

Count Property

Methods

Add Method

Refresh Method

Item Method

Remove Method (Collections)

ItemByID Method

 

解説

With the Defaults collection, you can:

  • Create a default.
  • Remove a default.

A process called binding enables a SQL Server default. A default can be bound to one or more columns or user-defined data types. A bound default cannot be removed.

To remove a SQL Server default

  1. Get the Default object referencing the targeted default from the Defaults collection by using the Item or ItemByID method. When extracting a Default object using the name of the referenced default, use the default owner name to qualify the default name, as in:

    Set oDefault = oDatabase.Defaults("UnitPrice", "dbo")
    
  2. Use the ListBoundColumns and ListBoundDatatypes methods of the Default object to report affected columns or user-defined data types. If either method returns items, use the UnbindFromColumn or UnbindFromDatatype method to resolve dependencies.

  3. Use the Remove method of the Defaults collection to remove the targeted default.

The Item method of the Defaults collection supports member selection using the default name or the ordinal position of the object in the collection. Additionally, when using the default name to select an object from the collection, the Item method allows owner name qualification of the targeted SQL Server default. For example:

Set oDefault = oDatabase.Defaults("UnitPrice", "stevenb")

The Remove method of the Defaults collection supports member targeting using either the default name or the ordinal position of the object in the collection. The Remove method does not support default owner name qualification when using the method to drop a default. When using the Defaults collection to remove a SQL Server default, it is suggested that you use either the Item or ItemByID method of the collection to extract the object, referencing the correct default, as illustrated earlier.

ms132920.note(ja-jp,SQL.90).gifメモ :
Creating or removing defaults by using the Defaults collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role db_ddladmin or a role with greater privilege.