|
1 | 1 | --- |
2 | 2 | title: "OLE automation return codes and error information" |
3 | | -description: Learn the details about OLE automation return codes and how to convert error code information. |
4 | | -ms.custom: "" |
5 | | -ms.date: "03/10/2022" |
| 3 | +description: Learn the details about OLE automation return codes and how to convert error code information. |
| 4 | +author: WilliamDAssafMSFT |
| 5 | +ms.author: wiassaf |
| 6 | +ms.reviewer: randolphwest |
| 7 | +ms.date: 12/21/2022 |
6 | 8 | ms.service: sql |
7 | | -ms.reviewer: "" |
8 | 9 | ms.subservice: stored-procedures |
9 | 10 | ms.topic: conceptual |
10 | | -helpviewer_keywords: |
| 11 | +helpviewer_keywords: |
11 | 12 | - "return codes [SQL Server]" |
12 | 13 | - "OLE Automation [SQL Server], return codes" |
13 | 14 | - "OLE Automation [SQL Server], errors" |
14 | | -author: WilliamDAssafMSFT |
15 | | -ms.author: wiassaf |
16 | 15 | monikerRange: ">=sql-server-2016" |
17 | 16 | --- |
18 | 17 | # OLE automation return codes and error information |
19 | 18 |
|
20 | 19 | [!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)] |
21 | 20 |
|
22 | | -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 0x800*nnnnn*, but when returned as an **int** value in a stored procedure return code, HRESULT has the form -214*nnnnnnn*. |
| 21 | +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 0x800*nnnnn*, but when returned as an **int** value in a stored procedure return code, HRESULT has the form -214*nnnnnnn*. |
23 | 22 |
|
24 | 23 | ## Example |
25 | 24 |
|
26 | | -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. |
27 | | - |
| 25 | +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. |
| 26 | + |
28 | 27 | You can use `CONVERT(binary(4), @hresult)` to convert an **int** HRESULT to a **binary** value. |
29 | 28 |
|
30 | | -For examples of supported conversion, see [H. Using CONVERT with binary and character data](../../t-sql/functions/cast-and-convert-transact-sql.md#h-using-convert-with-binary-and-character-data). |
| 29 | +For examples of supported conversion, see [H. Using CONVERT with binary and character data](../../t-sql/functions/cast-and-convert-transact-sql.md#h-use-convert-with-binary-and-character-data). |
31 | 30 |
|
32 | 31 | ## Next steps |
33 | 32 |
|
34 | | -- [sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md) |
| 33 | +- [sp_OAGetErrorInfo (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-oageterrorinfo-transact-sql.md) |
0 commit comments