Object Properties

SQL-DMO

SQL-DMO

Object Properties

SQL-DMO object properties provide access to instance data. For those SQL-DMO objects that reference specific Microsoft® SQL Server™ components, instance data identifies the referenced component for the application. For example:

  • The value of the Name property in a Table object instance referencing the Northwind..Employees table is Employees.

  • The value of the Name property in a Table object instance referencing the Northwind..Products table is Products.

Many properties are read-only, which expose informational data to the application. For example:

  • The Name property of a SystemDatatype object provides the name of a SQL Server data type; it can be used to assist users in column definition for table creation.

  • The OccurrenceCount property of an Alert object reports the number of times that an event has caused SQL Server Agent alert notification; an application could take exceptional action if the value is greater than 25.

Some properties can be both read and written. Altering the value of a read/write property causes alteration in the referenced component. For example:

  • The Length property of a Column object exposes the number of characters or bytes in a fixed length or variable length data type column. A column defined as varchar(12) reports 12 in the Length property of a referencing Column object. Setting the property to 15 causes the execution of an ALTER TABLE statement that changes the data type definition on SQL Server.

  • The CreationScriptOptions property of a TransArticle object specifies the attributes of table creation for the initial snapshot supporting the referenced article. By default, creation of a declarative referential integrity PRIMARY KEY constraint is not included as part of the table creation script. Setting the CreationScriptOptions property so that creation of a PRIMARY KEY constraint is included records the desired change in object creation scripting. The change in behavior, initiated in the SQL-DMO object, is reflected in the script created when the snapshot is next generated.

    Important  Modifying property values can have unintended consequences. For example, changing the Datatype or Length property of a Column object referencing an existing column alters the table containing the column and attempts to convert all data to the new data type. The process can be time-consuming and can fail. Applications that allow user property change should notify the user through a message or busy pointer and should provide appropriate error handling.

Some properties can be read or written when they do not reference an existing SQL Server component, but are read-only when they do. Typically, these properties name or identify a SQL Server component. For example:

  • The Name property of a LinkedServer object can be set when the LinkedServer object has been created by an application and will be added to the LinkedServers collection of a SQLServer object. After LinkedServer has been added successfully to the LinkedServers collection, the object references an existing linked server, and the Name property is no longer modifiable.

  • The FillFactor property of an Index or Key object provides an argument for index creation. When the index exists, the FillFactor property is not evaluated.

A few properties are write-only. Write-only properties are used to specify arguments for component creation only.