SQL Server Procedure Template
From SharpCoders Wiki
create procedure dbo.SomeProcedure
(
@inputParameter datatype = defaultvalue,
@outputParameter datatype output
)
as
--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;
ThrowError:
--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.