경고 경고!! 절대 함부로 사용하지 말 것.
본인이 원하는 바를 충분히 이해하고 사용하기 바라며,
이를 사용한 이후 발생되는 문제는 사용한 당사자가 책임지도록 할 것
SET NOCOUNT ON
GO
DECLARE DropBackupSP CURSOR
READ_ONLY
FOR SELECT name FROM sysobjects WHERE xtype = 'P' ORDER BY name
DECLARE @dropname varchar(256) , @DropSQL varchar(1000)
OPEN DropBackupSP
FETCH NEXT FROM DropBackupSP INTO @dropname
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
SELECT @DropSQL = 'DROP Proc ' + @dropname
EXEC (@DropSQL)
END
FETCH NEXT FROM DropBackupSP INTO @dropname
END
CLOSE DropBackupSP
DEALLOCATE DropBackupSP
GO
DECLARE DropTable CURSOR
READ_ONLY
FOR SELECT name FROM sysobjects WHERE xtype = 'U'
DECLARE @dropname varchar(256) , @DropSQL varchar(1000)
OPEN DropTable
FETCH NEXT FROM DropTable INTO @dropname
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
SELECT @DropSQL = 'DROP TABLE ' + @dropname
EXEC (@DropSQL)
END
FETCH NEXT FROM DropTable INTO @dropname
END
CLOSE DropTable
DEALLOCATE DropTable
GO