INF: SET SHOWLPLAN and the MS SQL Server ODBC Driver

Last reviewed: April 8, 1997
Article ID: Q140695

The information in this article applies to:
  • Microsoft SQL Server, versions 6.0 & 6.5

SUMMARY

This article discusses how the Microsoft SQL Server ODBC Driver returns SET SHOWPLAN data to an application.

MORE INFORMATION

SET SHOWPLAN is a proprietary Transact-SQL command for Microsoft SQL Server that can be used to obtain information about the execution plans that SQL Server builds for SQL statements. When this option is turned on in an ODBC environment:

   SQLExecDirect(hstmt, "SET SHOWPLAN ON", SQL_NTS);

the showplan information will be returned through SQLError().

After SET SHOWPLAN has been turned on, SQLExecute() or SQLExecDirect() will both return SQL_SUCCESS_WITH_INFO on successful calls. The application can retrieve the showplan output by then looping through calls to SQLError() until SQLError() returns SQL_NO_DATA_FOUND. Each call to SQLError() will return one line of showplan data in the following format:

   szSqlState="01000", *pfNativeError=6223,
   szErrorMsg="[Microsoft][ODBC SQL Server Driver][SQL Server] Table
               Scan"

where the actual showplan output is the part of the szErrorMsg string that comes after the literal [SQL Server]. The calls to SQLError() must be made immediately after the SQLExecute() or SQLExecDirect() function call that generates the output.


Additional query words: sql6 odbc debug
Keywords : kbenv kbinterop SSrvGen SSrvLan
Version : 6.0 6.5
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.