Microsoft KB Archive/156099

= HOW TO: Debug an Extended Stored Procedure =

Article ID: 156099

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 64-bit Edition

-



This article was previously published under Q156099



IN THIS TASK
SUMMARY
 * Debug an Extended Stored Procedure

REFERENCES



SUMMARY
This article describes how to properly debug an extended stored procedure.

back to the top

Debug an Extended Stored Procedure
 Make a debug build of the extended stored procedure DLL by using Microsoft Visual C. Make sure to generate the .pdb file. After you correctly build the DLL, copy it to the C:\Mssql\Binn folder. The DLL that SQL Server is loading and the .pdb file must be synchronized to properly handle breakpoints. Register the extended stored procedure by using the sp_addextendedproc stored procedure. For more information about the sp_addextendedproc stored procedure, see the "sp_addextendedproc" topic in SQL Server Books Online.  In the Project Settings dialog box, on the Debug tab, add the following:     Executable for debug session: C:\MSSQL\BINN\SQLSERVR.EXE Program arguments: -c

This starts SQL Server not as a service but in the Visual C Debug environment. By doing so, you can properly trap and handle your breakpoints.  Stop SQL Server if it is currently running by opening the Services tool in Control Panel, and then stopping the MSSQLSERVER service. Set your breakpoint, and then begin the debugging session.</li> After you properly start SQL Server and the cursor is blinking in the SQL Server command prompt window, minimize the window.</li> Use the ISQL/w query tool or Query Analyzer to run the extended stored procedure that you are going to debug.</li></ol>

When the breakpoint is encountered, the MSDEV environment stops, and you can begin the normal debugging process. back to the top

<div class="references_section">