sp_OASetProperty

Sets a property of an OLE object to a new value.

Syntax

sp_OASetProperty objecttoken, propertyname, newvalue [, index...]

where

objecttoken
Is the object token of an OLE object previously created by sp_OACreate.
propertyname
Is the property name of the OLE object to set to a new value.
newvalue
Is the new value of the property. It must be a value of the appropriate datatype.
index
Is an index parameter. If specified, it must be a value of the appropriate datatype.

Some properties have parameters. They are called indexed properties, and the parameters are called index parameters. A property can have multiple index parameters.

Remarks

This procedure returns a 0 when successful or a non-zero HRESULT when an error occurs.

Example

This example sets the HostName property (of the previously created SQLServer object) to a new value.

EXEC @hr = sp_OASetProperty @object, 'HostName', 'Gizmo'
IF @hr <> 0
BEGIN
    EXEC sp_displayoaerrorinfo @object, @hr
    RETURN
END