Export (0) Print
Expand All
Expand Minimize

YukonCLR Sample: Upgrading Stored Procedures to Work with SQL Server 2005

This sample demonstrates how to leverage an existing extended stored procedure and how to use C++ for developing CLR code. It comprises two solutions:

  • CppXP2Clr, which contains two projects:

    • xp_cheksum, an extended stored procedure with C++ functions

    • clr_checksum, a port using CLR pure

  • CppUdt is a CLR safe SQL Server 2005 project that contains user-defined data type

Security noteSecurity Note:

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

To build the sample

  • On the Build menu, select the Build Solution menu item.

To run the sample

  • On the Debug menu, select the Start menu item.

This sample requires the AdventureWorks sample database on a SQL Server 2005 server. After you load a SQL Server Class Library application in the Visual Studio integrated development environment (IDE), a message box will prompt you to specify connection information to a SQL Server. For this sample application, specify the AdventureWorks database.

How to:

  • Use an existing extended stored procedure

  • Move existing stored procedure functions to SQL Server 2005

  • Use new user-defined data types in SQL Server 2005

Yukon/CLR consists of two solutions, CppXP2Clr and CppUdt.

Solution CppXP2Clr consists of two projects, an extended stored procedure and a SQL Server Class Library project. The SQL/CLR project demonstrates the simplicity of moving native C++ function to SQL/CLR. The function checksum() will be used in both projects. The SQL/CLR project will be built using /clr:pure to leverage existing C++ functions.

Solution CppUdt is a SQL/CLR project built with /clr:safe and creates a user-defined data type (UDT). This project demonstrates using C++ to build SQL/CLR project with UDT.

Community Additions

ADD
Show:
© 2014 Microsoft