Section 10.2.  SMO Instance Classes for Administering Data Storage Objects Reference

JavaScript Editor Ajax toolkit     Ajax tutorials 



Main Page

Previous Page
Next Page

10.2. SMO Instance Classes for Administering Data Storage Objects Reference

This section describes the SMO classes used to administer SQL Server objects that store data. The classes are arranged into functional groups. A hierarchical diagram of these classes is shown in Figure 10-1, earlier in this chapter.

10.2.1. SQL Server Instances

The SMO classes used to manage SQL Server instances are described in Table 10-5.

Table 10-5. SMO classes for managing a SQL Server instance

Class

Description

Information

Represents nonconfigurable information about the SQL Server instance. The Information property of the Server class returns an Information object for the SQL Server instance.

Server

Represents a SQL Server instance.

ServerActiveDirectory

Represents Active Directory settings for a SQL Server instance. The ActiveDirectory property of the Server class returns a ServerActiveDirectory object for the SQL Server instance.

ServerEvent

Represents a SQL Server event that can be included in a ServerEventSet object.

ServerEventArgs

Represents the arguments used to report a server event.

ServerEvents

Represents the settings required for SQL Server event notification. The ServerEvents object is obtained using the Events property of the Server object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the ServerEvents class specifies the events to receive as either a ServerEventSet or ServerTraceEventSet object.

ServerEventSet

Represents a set of SQL Server events as ServerEvent objects.

ServiceMasterKey

Represents the service master key for the SQL Server instance. The ServiceMasterKey property of the Server class returns a ServiceMasterKey object for the SQL server instance.

ServerProxyAccount

Represents a SQL Server proxy account permitting impersonation of job-step execution. The ProxyAccount property of the Server class returns a ServerProxyAccount object for the SQL server instance.

ServerTraceEvent

Represents a SQL Server trace event. The ServerTraceEvent class contains a property for each trace event that the server can respond to.

ServerTraceEventSet

Represents a set of SQL Server trace events.

Settings

Represents configurable settings about the SQL Server instance. The Settings property of the Server class returns a Settings object for the SQL Server instance.


10.2.2. Databases

The SMO classes used to manage SQL Server databases are described in Table 10-6.

Table 10-6. SMO classes for managing databases

Class

Description

Database

Represents a SQL Server database.

DatabaseActiveDirectory

Represents Active Directory settings for a database. The ActiveDirectory property of the Database class returns a DatabaseActiveDirectory object for the database.

DatabaseCollection

Represents a collection of databases as Database objects. The Databases property of the Server class returns the databases defined on the SQL Server instance.

DatabaseEvent

Represents a SQL Server database event that can be included in a DatabaseEventSet object.

DatabaseEventArgs

Represents the arguments used to report a database event.

DatabaseEvents

Represents the settings required for SQL Server database-event notification. The DatabaseEvents object is obtained using the Events property of the Database object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the DatabaseEvents class specifies the events to receive as a DatabaseEventSet object.

DatabaseEventSet

Represents a set of SQL Server database events as a DatabaseEvent object

DatabaseOptions

Represents SQL Server database options. The DatabaseOptions property of the Database class returns a DatabaseOptions object for the database.

MasterKey

Represents the database master key used to symmetrically encrypt and decrypt the private key of certificates. The MasterKey property of the Database class returns a MasterKey object for the database.


10.2.3. Tables

The SMO classes used to manage SQL Server tables are described in Table 10-7.

Table 10-7. SMO classes for managing tables

Class

Description

Table

Represents a table.

TableCollection

Represents a collection of tables as Table objects. The Tables property of the Database class returns the tables defined in the database.

TableEvent

Represents a SQL Server table event that can be included in a TableEventSet object.

TableEvents

Represents the settings required for SQL Server table-event notification. The TableEvents object is obtained using the Events property of the Table object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the TableEvents class specifies the events to receive as a TableEventSet object.

TableEventSet

Represents a set of SQL Server table events as TableEvent objects.


10.2.4. Columns

The SMO classes used to manage SQL Server columns are described in Table 10-8.

Table 10-8. SMO classes for managing columns

Class

Description

Column

Represents a column.

ColumnCollection

Represents a collection of columns as Column objects.

The Columns property of the Table class returns the collection of columns in the table.

The Columns property of the View class returns the collection of columns in the view.

DefaultConstraint

Represents a default constraint on a column. A default constraint specifies the value to use for a column if a value is not specified when a row is inserted. The DefaultConstraint object is accessed through the DefaultConstraint property of the Column class.


10.2.5. Views

The SMO classes used to manage SQL Server views are described in Table 10-9.

Table 10-9. SMO classes for managing views

Class

Description

View

Represents a view.

ViewCollection

Represents a collection of views defined on a table as View objects. The Views property of the Database class returns the views defined in the database.

ViewEvent

Represents a SQL Server view event that can be included in a ViewEventSet object.

ViewEvents

Represents the settings required for SQL Server view-event notification. The ViewEvents object is obtained using the Events property of the View object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the ViewEvents class specifies the events to receive as a ViewEventSet object.

ViewEventSet

Represents a set of SQL Server view events as ViewEvent objects.


10.2.6. Indexes

The SMO classes used to manage SQL Server indexes are described in Table 10-10.

Table 10-10. SMO classes for managing indexes

Class

Description

Index

Represents an index.

IndexCollection

Represents a collection of indexes as Index objects.

The Indexes property of the Table class returns the collection of indexes defined on a table.

The Indexes property of the View class returns the collection of indexes defined on a view.

The Indexes property of the UserDefinedFunction class returns the collection of indexes defined on a user-defined function.

IndexedColumn

Represents a column in an index.

IndexedColumnCollection

Represents a collection of index columns as IndexColumn objects. The IndexColumns property of the Index class returns the collection of columns in the index.

IndexEvents

Represents the setting required for SQL Server index-event notification. The IndexEvents object is obtained using the Events property of the Index object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the IndexEvents class specifies the events to receive as an ObjectEventSet object.


10.2.7. Foreign Keys

A foreign-key constraint is a column or combination of columns used to enforce a link between two tables. The column or columns that make up the primary key in one table are referenced by a column or columns in a second table. The column or columns in the second table constitute a foreign key. The SMO classes used to manage SQL Server foreign-key constraints are described in Table 10-11.

Table 10-11. SMO classes for managing foreign keys

Class

Description

ForeignKey

Represents a foreign key.

ForeignKeyCollection

Represents a collection of foreign keys as ForeignKey objects. The ForeignKeys property of the Table class returns the collection of foreign keys defined on the table.

ForeignKeyColumn

Represents a column in a foreign key.

ForeignKeyColumnCollection

Represents a collection of foreign-key columns as ForeignKeyColumn objects. The Columns property of the ForeignKey class returns the collection of columns in the foreign key.


10.2.8. Check Constraints

Check constraints limit the values that can be stored in a column based on a logical expression that returns either TRue or false. A column can have multiple check constraints, and a check constraint can be applied to multiple columns. The SMO classes used to manage SQL Server check constraints are described in Table 10-12.

Table 10-12. SMO classes for managing check constraints

Class

Description

Check

Represents a check constraint.

CheckCollection

Represents a collection of check constraints as Check objects.

The Checks property of the Table class returns the collection of check constraints defined on a table.

The Checks property of the UserDefinedFunction class returns the collection of check constraints defined on a user-defined function.


10.2.9. Rules

A rule is used to restrict the values in a column. The SMO classes used to manage SQL Server rules are described in Table 10-13.

Table 10-13. SMO classes for managing rules

Class

Description

Rule

Represents the attributes of a rule.

RuleCollection

Represents a collection of rules as Rule objects. The Rules property of the Database class returns the collection of rules defined on the database.


Rules are included for backward compatibility and will be removed in a future version of SQL Server. Use a check constraint instead of a rule in new development.


10.2.10. Stored Procedures

The SMO classes used to manage SQL Server stored procedures are described in Table 10-14.

Table 10-14. SMO classes for managing stored procedures

Class

Description

StoredProcedure

Represents a stored procedure.

StoredProcedureCollection

Represents a collection of stored procedures as StoredProcedure objects. The StoredProcedures property of the Database class returns the collection of stored procedures in the database.

StoredProcedureEvent

Represents a stored-procedure event that can be included in a StoredProcedure EventSet object.

StoredProcedureEvents

Represents the settings required for SQL Server stored-procedure event notification. The StoredProcedureEvents object is obtained using the Events property of the StoredProcedure object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the StoredProcedureEvents class specifies the events to receive as a StoredProcedureEventSet object.

StoredProcedureEventSet

Represents a set of stored-procedure events as StoredProcedureEvent objects.

StoredProcedureParameter

Represents a parameter for a stored procedure.

StoredProcedureParameterCollection

Represents a collection of stored-procedure parameters as StoredProcedureParameter objects. The Parameters property of the StoredProcedure class returns the collection of parameters for the stored procedure.


10.2.11. Numbered Stored Procedures

The SMO classes used to manage SQL Server numbered stored procedures are described in Table 10-15.

Table 10-15. SMO classes for managing numbered stored procedures

Class

Description

NumberedStoredProcedure

Represents a numbered stored procedure.

NumberedStoredProcedureCollection

Represents a collection of numbered stored procedures as NumberedStoredProcedure objects. The NumberedStoredProcedures property of the StoredProcedure class returns the collection of numbered stored procedures.

NumberedStoredProcedureParameter

Represents a parameter for a numbered stored procedure.

NumberedStoredProcedureParameterCollection

Represents a collection of numbered stored-procedure parameters as NumberedStoredProcedureParameter objects. The Parameters property of the NumberedStoredProcedure class returns the collection of parameters for the numbered stored procedure.


Numbered stored procedures are included for backward compatibility and will be removed in a future version of SQL Server. Do not use them in new development.


10.2.12. Extended Stored Procedures

The SMO classes used to manage SQL Server extended stored procedures are described in Table 10-16.

Table 10-16. SMO classes for managing extended stored procedures

Class

Description

ExtendedStoredProcedure

Represents an extended stored procedure.

ExtendedStoredProcedureCollection

Represents a collection of extended stored procedures as ExtendedStoredProcedure objects. The ExtendedStoredProcedures property of the Database class returns the collection of extended stored procedures in a database.


Extended stored procedures are included for backward compatibility and will be removed in a future version of SQL Server. Do not use them in new development.


10.2.13. DML Triggers

The SMO classes used to manage SQL Server DML triggers are described in Table 10-17.

Table 10-17. SMO classes for managing DML triggers

Class

Description

trigger

Represents a DML trigger.

triggerCollection

Represents a collection of triggers as trigger objects.

The triggers property of the Table class returns the collection of triggers defined on a table.

The triggers property of the View class returns the collection of triggers defined on a view.

triggerEvents

Represents the settings required for SQL Server trigger-event notification. The TRiggerEvents object is obtained using the Events property of the TRigger object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the triggerEvents class specifies the events to receive as an ObjectEventSet object.


10.2.14. DDL Triggers

The SMO classes used to manage server- and database-scoped DDL triggers are described in Table 10-18.

Table 10-18. SMO classes for managing DDL triggers

Class

Description

DatabaseDdlTrigger

Represents a DDL trigger scoped to the database.

DatabaseDdlTriggerCollection

Represents a collection of DDL triggers scoped to the database as DatabaseDdlTrigger objects. The triggers property of the Database class returns the collection of triggers scoped to a database.

DatabaseDdlTriggerEvent

Represents a database DDL trigger event that can be included in a DatabaseDdlEventSet object.

DatabaseDdlTriggerEventSet

Represents a set of database DDL trigger events as DatabaseDdlTriggerEvent objects.

ServerDdlTrigger

Represents a DDL trigger scoped to the SQL Server instance.

ServerDdlTriggerCollection

Represents a collection of DDL triggers scoped to the SQL Server instance as ServerDdlTrigger objects. The triggers property of the Server class returns the collection of triggers scoped to the SQL Server instance.

ServerDdlTriggerEvent

Represents a server DDL trigger event that can be included in a ServerDdlEventSet object.

ServerDdlTriggerEventSet

Represents a set of server DDL trigger events as ServerTriggerEvent objects.


10.2.15. User-Defined Objects

The SMO classes used to manage user-defined aggregates, user-defined functions, and user-defined types are described in Table 10-19.

Table 10-19. SMO classes for managing user-defined objects

Class

Description

UserDefinedAggregate

Represents a user-defined aggregate.

UserDefinedAggregateCollection

Represents a collection of user-defined aggregates as UserDefinedAggregate objects. The UserDefinedAggregates property of the Database class returns the collection of user-defined aggregates in a database.

UserDefinedAggregateParameter

Represents a parameter used with a user-defined aggregate.

UserDefinedAggregateParameterCollection

Represents a collection of user-defined aggregate parameters as UserDefinedAggregateParameter objects. The UserDefinedAggregateParameters property of the UserDefinedAggregate class returns the collection of parameters for the user-defined aggregate.

UserDefinedDataType

Represents a user-defined type based on a SQL Server data type.

UserDefinedDataTypeCollection

Represents a collection of user-defined types as UserDefinedDataType objects. The UserDefinedDataTypes property of the Database class returns the collection of user-defined types in a database.

UserDefinedFunction

Represents a user-defined function.

UserDefinedFunctionCollection

Represents a collection of user-defined functions as UserDefinedFunction objects. The UserDefinedFunctions property of the Database class returns the collection of user-defined functions in a database.

UserDefinedFunctionEvent

Represents a SQL Server user-defined function event that can be included in a UserDefinedFunctionEventSet object.

UserDefinedFunctionEvents

Represents the settings required for SQL Server user-defined function event notification. The UserDefinedFunctionEvents object is obtained using the Events property of the UserDefinedFunction object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the UserDefinedFunctionEvents class specifies the events to receive as an UserDefinedFunctionEventSet object.

UserDefinedFunctionEventSet

Represents a set of user-defined function events as UserDefinedFunctionEvent objects.

UserDefinedFunctionParameter

Represents a parameter for a user-defined function.

UserDefinedFunctionParameterCollection

Represents a collection of user-defined function parameters as UserDefinedFunctionParameter objects. The Parameters property of the UserDefinedFunction class returns the collection of parameters for the user-defined function.

UserDefinedType

Represents a user-defined type based on a .NET data type.

UserDefinedTypeCollection

Represents a collection of user-defined types as UserDefinedType objects. The UserDefinedTypes property of the Database class returns the collection of user-defined types in a database.

UserDefinedTypeEvents

Represents the settings required for SQL Server user-defined type event notification. The UserDefinedTypeEvents object is obtained using the Events property of the UserDefinedType object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the UserDefinedTypeEvents class specifies the events to receive as an ObjectEventSet object.


10.2.16. Data Types

The SMO class used to manage SQL Server data types are described in Table 10-20.

Table 10-20. SMO classes for managing data types

Class

Description

DataType

Represents a SQL Server data type.

The DataType property of the following classes returns a DataType object representing its data type:

  • Column

  • NumberedStoredProcedureParameter

  • StoredProcedureParameter

  • UserDefinedAggregate

  • UserDefinedAggregateParameter

  • UserDefinedFunction

  • UserDefinedFunctionParameter


10.2.17. System Data Types

The SMO classes used to manage SQL Server system data types are described in Table 10-21.

Table 10-21. SMO classes for managing system data types

Class

Description

SystemDataType

Represents a system data type.

SystemDataTypeCollection

Represents a collection of system data types as SystemDataType objects. The SystemDataTypes property of the Server class returns the collection of system data types defined on a SQL Server instance.


10.2.18. Schemas

A schema is an ownership context for SQL Server objects such as tables, views, and stored procedures. The SMO classes used to manage SQL Server schemas are described in Table 10-22.

Table 10-22. SMO classes for managing schemas

Class

Description

Schema

Represents a SQL Server schema.

SchemaCollection

Represents a collection of schemas as Schema objects. The Schemas property of the Database class returns the schemas defined for a database.

SchemaEvents

Represents the setting required for SQL Server schema-event notification. The SchemaEvents object is obtained using the Events property of the Schema object and cannot be created as a standalone object.

The SubscribeToEvents( ) method of the SchemaEvents class specifies the events to receive as an ObjectEventSet object.


10.2.19. SQL Server Objects

The SMO classes used to manage SQL Server objects are described in Table 10-23.

Table 10-23. SMO classes for managing SQL Server objects

Class

Description

ObjectAlteredEventArgs

Represents the arguments passed by the event that is raised when an object is altered.

ObjectCreatedEventArgs

Represents the arguments passed by the event that is raised when an object is created.

ObjectDroppedEventArgs

Represents the arguments passed by the event that is raised when an object is dropped.

ObjectEvent

Represents a SQL Server object event that can be included in an ObjectEventSet object.

ObjectEventSet

Represents a set of object events as ObjectEvent objects.

ObjectPermission

Represents a SQL Server object permission.

ObjectPermissionInfo

Represents information about a SQL Server object permission.

ObjectPermissionSet

Represents a set of SQL Server object permissions as ObjectPermission objects.

ObjectProperty

Represents a set of attributes for a SQL Server object property.

ObjectRenamedEventArgs

Represents the arguments passed by the event that is raised when an object is renamed.



Previous Page
Next Page


JavaScript Editor Ajax toolkit     Ajax tutorials