Friday, October 24, 2014

SQL Server - Stored Proc Skeleton


USE [collateral]
GO

if exists(select * from sys.objects where Name = 'sproc_name' and type = 'P')
 drop procedure sproc_name 
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE sproc_name 
 @intParam int
AS
BEGIN
 SET NOCOUNT ON;

 begin transaction [txn]

 begin try

  -- sproc sql here

 commit transaction [txn]

 end try
 begin catch
  rollback transaction [txn]
 end catch

END
GO

No comments:

Post a Comment

comment: