Welcome to weblogs.com.pk Sign in | Join | Help

SQL Server Procedure Template

From SharpCoders Wiki


create procedure dbo.SomeProcedure
         @inputParameter datatype = defaultvalue,
         @outputParameter datatype output
 --Dont send rows affected to client
 set nocount on;
 --Automatically rollback transactions on error
 set xact_abort on;
 --Output parameters initialization
 --Error handling
 declare @@errorMessage nvarchar(500);
 select @@errorMessage ='Internal Error';
 --In case of any error simply
 --        select @@errorMessage and goto ThrowError;
 --Check inputs
 --Initialize Local Variables
 return 0;
         --print @@errorMessage;
         raiserror (@@errorMessage, 16, 1);
         return -1;


If you have better versions, add them to the wiki page.

And in case you havn’t explore, visit SqlServer page for SQL Server resources.

Published Friday, June 3, 2005 9:41 PM by khurram
Filed under: ,


No Comments

New Comments to this post are disabled