次の方法で共有


Databases Collection

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

The Databases collection contains Database objects that expose Microsoft SQL Server databases.

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

Properties

Count Property

 

Methods

Add Method

Refresh Method

Item Method

Remove Method (Collections)

ItemByID Method

 

解説

With the Databases collection, you can:

  • Create a SQL Server database.
  • Remove a SQL Server database.

For more information about creating databases, see Database Object.

To remove a database

  1. Use the Item or ItemByID method of the Databases collection to extract the Database object referencing the target database. When extracting a Database object by name, use the database owner name to qualify the database name, as in:

    Set oDatabase = oSQLServer.Databases("Northwind", "stevenb")
    
  2. Use the Remove method of the Database object to drop the referenced database.

    ms132129.note(ja-jp,SQL.90).gifメモ :
    Using the Remove method of the Database object or Databases collection drops the referenced database on an instance of SQL Server. The action is not recoverable.

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

Set oDatabase = oSQLServer.Databases("Northwind", "stevenb")

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

ms132129.note(ja-jp,SQL.90).gifメモ :
Creating or removing databases by using the Databases collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of one of the fixed roles sysadmin or dbcreator.