Object Hierarchy Syntax (Transact-SQL)
The propertyname parameter of sp_OAGetProperty and sp_OASetProperty and the methodname parameter of sp_OAMethod support an object hierarchy syntax that is similar to that of Microsoft Visual Basic. When this special syntax is used, these parameters have the following general form.
If TraversedObject is not specified, PropertyOrMethod is required.
If PropertyOrMethod is not specified, the TraversedObject is returned as an object token output parameter from the OLE Automation stored procedure. If PropertyOrMethod is specified, the property or method of the TraversedObject is called, and the property value or method return value is returned as an output parameter from the OLE Automation stored procedure.
If any item in the TraversedObject list does not return an OLE object, an error is raised.
For more information about Visual Basic OLE object syntax, see the Visual Basic documentation.
For more information about HRESULT Return Codes, see sp_OACreate (Transact-SQL).
The following are examples of object hierarchy syntax that use a SQL-DMO SQLServer object.
-- Get the AdventureWorks2008R2 Person.Address Table object.
EXEC @hr = sp_OAGetProperty @object,
'Databases("AdventureWorks2008R2").Tables("Person.Address")',
@table OUT
-- Get the Rows property of the AdventureWorks2008R2 Person.Address table.
EXEC @hr = sp_OAGetProperty @object,
'Databases("AdventureWorks2008R2").Tables("Person.Address").Rows',
@rows OUT
-- Call the CheckTable method to validate the
-- AdventureWorks2008R2 Person.Address table.
EXEC @hr = sp_OAMethod @object,
'Databases("AdventureWorks2008R2").Tables("Person.Address").CheckTable',
@checkoutput OUT