Tutorial: Call a SQL CLR Stored Procedure Single-project by Data Name

Guides you through the process of setting up the provided SQLCLRTutorialSPCall Visual Studio solution in a single assembly that uses a data name to call stored procedures.


  • Review the Assumptions and Before you begin a tutorial sections in the Tutorials: SQL CLR Stored Procedures Called via COBOL and JCL topic to ensure that your environment is set up properly.
  • Complete Tutorial: Prepare the SQL CLR Stored Procedures Environment, including configuration of the JCLSPSDN enterprise server region.

Demonstration solution - SQLCLRTutorialSPCall single-project by data name

Note: For an overview of the base application used in this and other SQL CLR tutorials in this series, see the Demonstration solutions section in the Tutorials: SQL CLR Stored Procedures Called via COBOL and JCL topic.

This tutorial uses a version of the SQLCLRTutorialSPCall solution created using the SQL Server Database project template and then modified to demonstrate calling a SQL CLR stored procedure by a data name. It includes the following projects:

SQLCLRTutorial Project
The SQLCLRTutorial project in this tutorial contains both the required procedural COBOL programs and the stored procedure programs. These are built into one DLL that is deployed to the sample SQLCLR_Test SQL Server database:
A.cbl Procedural COBOL programs
SP1.cbl SQL CLR stored procedures
A.cbl, B.cbl, C.cbl
Procedural COBOL programs that each increment the COBOL program counter by 1.
SP1.cbl contains stored procedure code. At run time, SQL Server meta-data identifies the assembly containing this stored procedure code, and then loads the assembly into the SQL Server database. This loaded assembly, SQLCLRTutorial, is the only assembly; therefore all calls from SP1.cbl to other programs and stored procedures are found in it. For example, when the stored procedure code in SP1.cbl calls program A, it finds A in the loaded SQLCLRTutorial assembly. SP1 calls programs A and C, and calls stored procedure SP2.
Stored procedure that calls programs A and B, and also increments the stored procedure counter by 10.
SPCall Project
A COBOL/JCL project added to the solution as a customization. It contains a native COBOL program that initiates the first call to a SQL CLR stored procedure, and the JCL that invokes the program.
Invokes SPCall.cbl:
Invoked by SPCall.jcl, this program calls the SP1 stored procedure in the SQLCLRTutorial project.
       move "SP1" to progname
       exec sql
            call :progname (:countval INOUT)
SQLCLRTutorial.Publish Project
Also created by default from the SQL Server Database project template, the SQLCLRTutorial.Publish project does not contain any application code. Its purpose is to create the deployment package for the solution and to deploy it. The publishing process creates the stored procedures that call the into the DLL that SQL Server executes in a SQL CLR run-time environment. The SQL CLR run time works with the COBOL run-time. Publishing includes deploying both of these run-times.


To complete this tutorial, progress through these topics in the order presented here. The bottom of each topic provides Next topic and Previous topic navigational links to help you proceed in the proper sequence: