|
Go to product support center
|
SQL Prompt code snippets forum
|
Create a New SP with Informational Headers & TRY/CATCH Block
|
Search in SQL Prompt code snippets forum
|
|
|
|
|
|
|
| Author |
Message |
AndrewJacksonZA
Joined: 05 May 2010 Posts: 17 Location: Johannesburg, South Africa
|
Posted: Wed Nov 03, 2010 10:59 am Post subject: Create a New SP with Informational Headers & TRY/CATCH Block |
|
|
Snippet: csp
Description: Create a new stored procedure with informational headers and a TRY/CATCH block.
Code:
| Code: |
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: A. Jackson
-- Create date: 2010/<Create Month,,12>/<Create Day,,31>
-- Description: <Description,,>
--
-- Modifications:
-- Author:
-- Date: YYYY/MM/DD
-- Description:
-- :
-- =============================================
CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
-- WITH ENCRYPTION, RECOMPILE, EXECUTE AS CALLER|SELF|OWNER| 'user_name'
-- @parameter_name AS scalar_data_type ( = default_value ), ...
AS
BEGIN
BEGIN TRY
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
$CURSOR$
END TRY
BEGIN CATCH
EXEC [dbo].[dba_Error_Handler] @isDynamicSQL = <Is this using Dynamic SQL?,bit,0>
END CATCH
END
GO |
Use CTLR+SHIFT+M to bring up a dialog box that let's you enter <these, values> quickly and easily.
Please see my blog entry "A Way to Handle Raised Errors in Both Dynamic and Static SQL Code" for more information about [dba_Error_Handler]. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group