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 Note |
---|
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties. |
To get samples and instructions for installing them:
To access samples from Visual Studio
On the Help menu, click Samples.
By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.
- For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.
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.
Requirements
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.
Demonstrates
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
How it Works
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.