Thursday, September 6, 2012

Create a Stored Procedure if don't exists

There are couple of processes around that:
1. Dropping the stored procedure if it exists and recreating
2. Creating the stored if it don't exists , otherwise altering it

Approach 1 :

Approach 2:
if object_id('[AddArqueEvalConfig]') is null
    exec ('create procedure dbo.[AddArqueEvalConfig] as select 1')
go
    alter procedure [dbo].[AddArqueEvalConfig] 

    @CustomerName_ nvarchar(max),
--…..other sql parameters
    
    AS
BEGIN

--Your sql statements here

END


No comments:

Post a Comment