Gets a property value of an OLE object.
sp_OAGetProperty objecttoken, propertyname, [propertyvalue OUTPUT
[, index...]]
where
Some properties have parameters. They are called indexed properties, and the parameters are called index parameters. A property can have multiple index parameters.
If the property returns a single value, either:
Or
If the property returns an OLE object, you must specify a local variable of datatype int for the propertyvalue parameter. An object token will be stored in the local variable, and this object token can be used with other OLE Automation stored procedures.
If the property returns an array with one or two dimensions, the array will be returned to the client as a results set as follows:
When the property returns an array, if propertyvalue is specified, it is set to NULL.
If propertyvalue is specified, but the property does not return a value, an error occurs. If the property returns an array with more than two dimensions, an error occurs.
You can also use sp_OAMethod to get a property value.
This procedure returns a 0 when successful or a non-zero HRESULT when an error occurs.
This example gets the HostName property (of the previously created SQLServer object) and stores it in a local variable.
DECLARE @property varchar(255) EXEC @hr = sp_OAGetProperty @object, 'HostName', @property OUT IF @hr <> 0 BEGIN EXEC sp_displayoaerrorinfo @object, @hr RETURN END PRINT @property
This example gets the HostName property (of the previously created SQLServer object) and returns it to the client as a results set.
EXEC @hr = sp_OAGetProperty @object, 'HostName' IF @hr <> 0 BEGIN EXEC sp_displayoaerrorinfo @object, @hr RETURN END