Its very frequent that we need to check whether particular store procedure exist in database or not?
If stored procedure exist then delete the stored procedure, otherwise we have to toggle between Create Procedure and Alter Procedure.
Below is the SQL to delete the stored procedure if exist.
IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[SPNAME]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) BEGIN DROP PROCEDURE dbo.SPNAME END
Leave a Reply