Created
September 12, 2012 09:30
-
-
Save Novakov/3705522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists(select * from sys.objects where object_id = OBJECT_ID(N'dbo.sp_drop') and type in (N'P')) | |
DROP PROCEDURE sp_drop; | |
GO | |
CREATE PROCEDURE sp_drop | |
@type nvarchar(2), | |
@name nvarchar(200) | |
AS | |
BEGIN | |
set nocount on; | |
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(@name) AND type in (@type)) | |
BEGIN | |
declare @t nvarchar(20) | |
if @type = N'U' | |
set @t = N'table' | |
else if @type = 'V' | |
set @t = N'view' | |
else if @type = N'P' | |
set @t = N'procedure'; | |
declare @sql nvarchar(200) | |
set @sql = N'drop ' + @t + N' ' + @name | |
exec sp_executesql @sql | |
END | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment