Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gregoryagu
Yak Posting Veteran
80 Posts |
Posted - 2008-07-31 : 17:21:57
|
--Drops a Procedure if it exists and prints a message with the result.CREATE PROCEDURE [dbo].[Utils_DropProcedure] ( @ProcedureName varchar(128) )ASBEGIN Declare @SQL varchar(4000) set @SQL = 'IF (EXISTS (SELECT * FROM dbo.sysobjects ' + ' WHERE id = OBJECT_ID(''' + @ProcedureName + ''') AND OBJECTPROPERTY(id,''IsProcedure'') = 1))' + 'BEGIN PRINT ''Dropping the Procedure:'' PRINT ''' + @ProcedureName + ''' DROP PROCEDURE [' + @ProcedureName + '] END ELSE BEGIN PRINT ''Procedure Not Found:''' + 'Print ''' + @ProcedureName + ''' END' EXECUTE (@SQL)ENDGO |
|
|
|
|