Obtains OLE Automation error information.
sp_OAGetErrorInfo [objecttoken ]
[, source OUTPUT]
[, description OUTPUT]
[, helpfile OUTPUT]
[, helpid OUTPUT]
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.
If no output parameters are specified, the error information is returned to the client as a result set.
Column names | Data type | Description |
---|---|---|
Error | binary(4) | Binary representation of the error number |
Source | varchar(nn) | Source of the error |
Description | varchar(nn) | Description of the error |
Helpfile | varchar(nn) | Help file for the source |
HelpID | int | Help context ID in the Help source file |
Each call to an OLE Automation stored procedure (except sp_OAGetErrorInfo) resets the error information; therefore, sp_OAGetErrorInfo obtains error information only for the most recent OLE Automation stored procedure call. Note that because sp_OAGetErrorInfo does not reset the error information, it can be called multiple times to get the same error information.
This table lists OLE Automation errors and their common causes.
Error and HRESULT | Common cause |
---|---|
Bad variable type (0x80020008) |
Data type of a Transact-SQL value passed as a method parameter did not match the Microsoft® Visual Basic® data type of the method parameter, or a NULL value was passed as a method parameter. |
Unknown name (0x8002006) |
Specified property or method name was not found for the specified object. |
Invalid class string (0x800401f3) |
Specified ProgID or CLSID has not been registered as an OLE object on the computer running Microsoft SQL Server™. |
Server execution failed (0x80080005) |
Specified OLE object is registered as a local OLE server (.exe file) but the .exe file could not be found or started. |
The specified module could not be found (0x8007007e) |
Specified OLE object is registered as an in-process OLE server (.dll file), but the .dll file could not be found or loaded. |
Type mismatch (0x80020005) |
Data type of a Transact-SQL local variable used to store a returned property value or a method return value did not match the Visual Basic data type of the property or method return value. Or, the return value of a property or a method was requested, but it does not return a value. |
Parameter not found (0x80020004) |
Named parameter was specified before a positional parameter.
Ensure that all named parameters are specified after all positional parameters. |
The parameter is incorrect (0x80070057) |
Number specified as the context parameter of sp_OACreate was not valid. |
For more information about processing HRESULT Return Codes, see OLE Automation Return Codes and Error Information.
This example displays OLE Automation error information.
DECLARE @output varchar(255)
DECLARE @hr int
DECLARE @source varchar(255)
DECLARE @description varchar(255)
PRINT 'OLE Automation Error Information'
EXEC @hr = sp_OAGetErrorInfo @object, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END