次の方法で共有


DRIDefault Object

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

The DRIDefault object represents the properties of a Microsoft SQL Server column DEFAULT constraint.

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

Properties

Name Property

Text Property

Methods

Remove Method (Objects)

Script Method

解説

The SQL Server column DEFAULT constraint is used to generate data for the column when none is supplied by the user on INSERT statement execution. With the DRIDefault object, you can:

  • Set the DEFAULT constraint for a SQL Server column.
  • Remove the DEFAULT constraint from a SQL Server column.

The Name property of the DRIDefault object uses the SQL Server data type sysname. Name is optional when using the object to create a DEFAULT constraint for a SQL Server column. If Name is not specified, SQL Distributed Management Objects (SQL-DMO) generates an appropriate value.

When setting the Text property of a DRIDefault object, specify only the text for the default. You do not need to build the constraint clause because SQL-DMO does that. The Text property value must evaluate to a constant. For more information about limitations on the Text property, see the description of the DEFAULT constraint in CREATE TABLE (Transact-SQL).

Delimiters that specify constant strings must be present in the Text property value when specifying string data as part of the property. For example, to specify the string "unknown" as the default, use 'unknown'.

To set a DEFAULT constraint on a new SQL Server column

  1. Create a Table object.

  2. Create a Column object.

  3. Get the DRIDefault object from the new Column object.

  4. Set the Text property of the DRIDefault object to the default for the column.

  5. Add the Column object to the Columns collection of the new Table object.

  6. Add the Table object to the Tables collection of a connected Database object.

To set a DEFAULT constraint on an existing SQL Server column

  1. Get a Table object from the Tables collection of a connected Database object.

  2. Use the BeginAlter method of the Table object to mark the beginning of changes to the SQL Server table.

  3. Get the Column object you want from the Columns collection of the selected Table object.

  4. Get the DRIDefault object from the new Column object.

  5. Set the Text property of the DRIDefault object to the default for the column.

  6. Use the DoAlter method of the Table object to submit changes to the instance of SQL Server.

参照

関連項目

Column Object
Table Object

ヘルプおよび情報

SQL Server 2005 の参考資料の入手