OLE automation return codes and error information

Applies to: SQL Server

The OLE automation system stored procedures return an int return code that is the HRESULT returned by the underlying OLE automation operation. An HRESULT of 0 indicates success. A nonzero HRESULT is an OLE error code of the hexadecimal form 0x800nnnnn, but when returned as an int value in a stored procedure return code, HRESULT has the form -214nnnnnnn.

Example

For example, passing an invalid object name (SQLDMO.Xyzzy) to sp_OACreate causes the procedure to return an int HRESULT of 2147221005, which is 0x800401f3 in hexadecimal.

You can use CONVERT(binary(4), @hresult) to convert an int HRESULT to a binary value.

For examples of supported conversion, see H. Using CONVERT with binary and character data.

Next steps