sp_OASetProperty (Transact-SQL)
Applies to: SQL Server
Sets a property of an OLE object to a new value.
Transact-SQL syntax conventions
sp_OASetProperty objecttoken
, propertyname
, newvalue
[ , index... ]
[ ; ]
The object token of an OLE object previously created by sp_OACreate
.
The property name of the OLE object to set to a new value.
The new value of the property, and must be a value of the appropriate data type.
An index parameter. If specified, index must be a value of the appropriate data type.
Some properties have parameters. These properties are called indexed properties, and the parameters are called index parameters. A property can have multiple index parameters.
Note
The parameters for this stored procedure are specified by position, not name.
0
(success) or a nonzero number (failure) that is the integer value of the HRESULT returned by the OLE Automation object.
For more information about HRESULT return codes, see OLE automation return codes and error information.
Requires membership in the sysadmin fixed server role or execute permission directly on this stored procedure. The Ole Automation Procedures server configuration option must be enabled to use any system procedure related to OLE Automation.
The following 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_OAGetErrorInfo @object
RETURN
END;