OLE Automation Objects in Transact-SQL

Transact-SQL includes several system stored procedures that allow OLE Automation objects to be referenced in Transact-SQL batches, stored procedures, and triggers. These system stored procedures run as extended stored procedures, and the OLE Automation objects that are executed through the store procedures run in the SQL Server address space in the same way as an extended stored procedure.

The OLE Automation stored procedures allow Transact-SQL batches to reference:

The first step to using an OLE Automation object in Transact-SQL is to call the sp_OACreate system stored procedure to create an instance of the object in the SQL Server address space.

After an instance of the object has been created, use these stored procedures to work with the properties, methods, and error information of the object:

When there is no more need for the object, call sp_OADestroy to deallocate the instance of the object created with sp_OACreate.

OLE Automation objects return data through property values and methods. sp_OAGetProperty and sp_OAMethod return these data values in the form of a result set.

The scope of an OLE Automation object is a batch. All references to the object must be contained in a single batch, stored procedure, or trigger.

When referencing objects, the SQL Server OLE Automation objects support traversing the object to other objects it contains. For example, when using the SQL-DMO SQLServer object, references can be made to databases and tables contained on that server. For more information, see Object Hierarchy Syntax.

See Also:
sp_OACreate sp_OAGetProperty
sp_OASetProperty sp_OAMethod
sp_OAGetErrorInfo sp_OADestroy

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.