sql drop stored procedure if exists

Drop and re-create procedure if it exists in T-SQL not working

 

IF EXISTS(SELECT 1

          FROM   INFORMATION_SCHEMA.ROUTINES

          WHERE  ROUTINE_NAME = 'YOUR_STORED_PROCEDURE_NAME'

                 AND SPECIFIC_SCHEMA = 'dbo')

  BEGIN

      DROP PROCEDURE YOUR_STORED_PROCEDURE_NAME

  END

GO




CREATE PROCEDURE dbo.YOUR_STORED_PROCEDURE_NAME

AS-- Logic Comes Here

GO
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s