Creating a Stored Procedure in C#

Add a stored procedure item to your database project by right-clicking the project and selecting Add, New Item. From the Add New Item dialog, you select the SQL CLR C# category and then the SQL CLR C# Stored Procedure project item, as shown in Figure 13.29. Let’s name the stored procedure UpdateEmployeeLogin.

Image

FIGURE 13.29 Adding a C# stored procedure.

A new class is added to the project. Listing 13.1 shows the base code that shows up within the new class file. You can add your custom code to the static void routine UpdateEmployeeLogin.

Note

Earlier versions of Visual Studio had a separate project type (SQL ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.