Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Gama and Naughter

Using the framework

To use the XP++ framework to build an XP you should use the following steps:

1. Use one of the Appwizards in Microsoft Visual C++ to generate the basic code for a Win32 dll. Depending on your needs, you can use the ATL COM Appwizard, MFC Appwizard DLL or Win32 Dynamic-Link Library wizards if you are using Microsoft Visual C++ v6.

2. Add the two files ‘xp_pp.h’ and ‘xp_pp.cpp’ to your project. These two files comprise the XP++ class framework.

3. Optionally add IMPLEMENT_VERSION_XP() to support the __GetXpVersion function.

4. Modify the stdafx.h header file to include ‘srv.h’. This contains the definitions for the ODS API.

5. Create your new XP class say ‘CYourExtendedStoredProcedure’ in a new set of ‘YourStoredProcedure.cpp’ and ‘YourStoredProcedure.h’ files. This class should derive from CExtendedStoredProcedure and should override the ‘DisplayUsage‘ and ‘Run’ methods of its base class.

6. Also add DECLARE_XP_PARAMETERS() to the declaration of CYourExtendedStoredProcedure in ‘YourStoredProcedure.h’.

7. Define the layout of the parameters to your XP, using the BEGIN_IMPLEMENT_XP_PARAMETERS, END_IMPLEMENT_XP_PARAMETERS and XP_..._PARAMETER macros in ‘YourStoredProcedure.cpp’.

8. Implement the ‘DisplayUsage’ method to display info on using your XP.

9. Implement the core logic of your XP in the method ‘CYourExtendedStoredProcedure::Run’.

10. Add IMPLEMENT_XP(theNameOfYourXP, CYourExtendedStoredProcedure) to the main cpp module of your project. Also #include YourStoredProcedure.h in this module.

11. Compile, Unit test, Debug and Deploy!.

To add additional XP’s to your dll, simple repeat steps 5 – 11. Please also note that the framework will work equally as well in a plain SDK DLL, MFC DLL or ATL DLL. Also included in the framework example XP are Unicode build configurations if you want to produce Unicode versions of the XP. The framework as well as all its samples have also been tested on Visual Studio .NET 2003.

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter