次の方法で共有


Column Object

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

The Column object represents the properties of a single column in a Microsoft SQL Server table.

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

Properties

AllowNulls Property

InPrimaryKey Property

AnsiPaddingStatus Property

IsComputed Property

ComputedText Property

IsRowGuidCol Property

Datatype Property

Length Property

Default Property (Column, UserDefinedDatatype)

Name Property

DefaultOwner Property

NotForRepl Property

FullTextIndex Property

NumericPrecision Property

ID Property

NumericScale Property

Identity Property

PhysicalDatatype Property

IdentityIncrement Property

Rule Property

IdentitySeed Property

RuleOwner Property

Methods

BindDefault Method

Remove Method (Objects)

BindRule Method

UpdateStatisticsWith Method (Column, Index)

ListKeys Method

 

解説

With the Column object, you can:

  • Define columns of a new SQL Server table.
  • Define a new column for an existing SQL Server table.
  • Drop an existing column from a SQL Server table.
  • List the references of a SQL Server column.

The Name property of a Column object uses the SQL Server data type sysname. The Name property must be unique within the names of columns in the SQL Server table.

Column object properties can be set before the Column object is added to the Columns collection of a Table object.

To define columns for a new SQL Server table

  1. Create a Table object.

  2. Set the Name property of the Table object.

  3. Create a Column object.

  4. Set the Name property of the Column object.

  5. Set properties that define the column data type. For example, to specify a column with a char(5) data type, set the Datatype property to char and the Length property to 5.

  6. Set other properties.

  7. Add the Column object to the Columns collection of the Table object.

  8. Repeat Steps from 3 through 7 until all columns are defined.

  9. Add the Table object to the Tables collection of a Database object.

To add a new column to a SQL Server table

  1. Create a Column object.

  2. Set the Name property.

  3. Set properties that define the column data type. For example, to specify a column with a char(5) data type, set the Datatype property to char and the Length property to 5.

  4. Set other properties.

  5. Get the appropriate Table object from the Tables collection of a Database object.

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

  7. Add the Column object to the Columns collection of the Table object.

  8. Use the DoAlter method of the Table object to submit the changed table definition to the instance of SQL Server.

To drop a column from a SQL Server table

  1. Get the appropriate Table object from the Tables collection of a 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 appropriate Column object from the Columns collection of the Table object.

  4. Use the Remove method of the Column object to drop the column from the SQL Server table.

  5. Use the DoAlter method of the Table object to submit the changed table definition to the instance of SQL Server.

ms141050.note(ja-jp,SQL.90).gifメモ :
The Column object is compatible with instances of SQL Server version 7.0 and later. However, the Column2 object extends the functionality of the Column object for use with features that were added in SQL Server 2000.

参照

関連項目

Column2 Object

ヘルプおよび情報

SQL Server 2005 の参考資料の入手