Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sp_OASetProperty (Transact-SQL)


Applies To: SQL Server 2014, SQL Server 2016 Preview

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

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

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


Is the object token of an OLE object that was previously created by sp_OACreate.


Is the property name of the OLE object to set to a new value.


Is the new value of the property, and must be a value of the appropriate data type.


Is 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.


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.

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
   EXEC sp_OAGetErrorInfo @object
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft