O'Reilly logo

Writing Stored Procedures for Microsoft SQL Server by Matthew Shepker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automating Code Creation

In the previous chapter, I gave you code that you can run to create a stored procedure that creates a stored procedure that inserts data into the table that you specify. The stored procedure in Listing 8.3 creates the code that can be run to create a stored procedure that updates any table that you pass in.

Code Listing 8.3. Creating an Update Procedure
 CREATE PROC usp_create_update_proc @vchTable varchar(30), @vchKey varchar(30) AS SET NOCOUNT ON /* Declare the variable */ DECLARE @vchName varchar(30) DECLARE @intType int DECLARE @vchNameType varchar(255) DECLARE @vchPrint varchar(255) DECLARE @vchName2 varchar(30) DECLARE @vchNameType2 varchar(255) DECLARE @vchMessage varchar(255) DECLARE @intReturnVal int DECLARE ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required