• subscribe
August 11, 2000 10:46 AM

Using sp_DisplayOAErrorInfo

SQL Server Pro
InstantDoc ID #9729

SQL Server's sp_OAGetErrorInfo stored procedure provides all the information you need to pass up to your application's middle and client tiers when an error occurs. However, writing an error handler to pass this error information can be time-consuming. In addition, if you don't interactively run the procedure that automates the COM object but instead schedule the procedure with the SQL Agent (SQL Executive in SQL Server 6.5), you'll want to log the information somehow.

Fortunately, SQL Server Books Online (BOL) includes a sample stored procedure called sp_DisplayOAErrorInfo. This procedure calls sp_OAGetErrorInfo for you and combines the returned values into formatted strings. The procedure then passes these strings to a T-SQL print statement, which outputs them either as messages to an ADO or RDO client when you run the procedure interactively or as entries in the SQL Agent log when you schedule the procedure.

To use sp_DisplayOAErrorInfo, place the following code after a call to any of the automation procedures. (This example assumes that @Object holds the object's object token and that @hr holds the return value from the automation call.)

If @hr <> 0
BEGIN
Exec sp_DisplayOAErrorInfo @Object, @hr
Return
END

To find stored procedure sp_DisplayOAErrorInfo's sample source code, look in BOL under the heading "sp_OAGetErrorInfo" for SQL Server 7.0 or "HRESULT Return Codes" for SQL Server 6.5.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...