tag:blogger.com,1999:blog-3682177839638728927.post3578818316930079202..comments2024-03-09T14:05:29.528+05:30Comments on SQL: Check If Stored Procedure Exists, Else Drop It and Recreate – SQL ServerAnonymoushttp://www.blogger.com/profile/09453699184523060639noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-3682177839638728927.post-45599203202281679452011-06-18T12:39:00.773+05:302011-06-18T12:39:00.773+05:30You can do this also
IF EXISTS(SELECT * FROM dbo....You can do this also<br /><br />IF EXISTS(SELECT * FROM dbo.sysobjectsWHERE id = object_id(N'[dbo].[YourStoredProcName]')and OBJECTPROPERTY(id, N'IsProcedure') = 1) GO ALTER PROCEDURE dbo.YourStoredProcNameAS-- Logic Comes Here GOAnonymoushttps://www.blogger.com/profile/09453699184523060639noreply@blogger.comtag:blogger.com,1999:blog-3682177839638728927.post-81490603674135473792011-06-18T03:00:35.825+05:302011-06-18T03:00:35.825+05:30These do drop and recreate the procedure but then ...These do drop and recreate the procedure but then you would lose any permissions assigned to it. <br /><br />Is there a way to check to see if it exists and if it does then change from a CREATE to an ALTER?Anonymousnoreply@blogger.com