sql2005删除数据库中所有表,视图,存储过程

declare @table varchar(600)

while (select count(*) from sysobjects where type='u')>=1
 begin
  set @table=(select top 1 name from sysobjects where type='u')
  set @table='drop table '+@table
  exec(@table)
 end
select  name,type from sysobjects where type='u'

declare @table varchar(600)
while (select count(*) from sysobjects where type='v')>=1
 begin
  set @table=(select top 1 name from sysobjects where type='v')
  set @table='drop view '+@table
  exec(@table)
 end
select  name,type from sysobjects where type='v'


DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT NAME FROM SYSOBJECTS WHERE TYPE='P' AND STATUS>=0 and uid=1)
BEGIN
SELECT TOP 1 @STRING='DROP PROCEDURE '+NAME FROM   SYSOBJECTS    WHERE   TYPE = 'P' AND STATUS>=0 and uid=1
--SELECT @STRING
EXEC(@STRING)
END

原文地址:https://www.cnblogs.com/zwei1121/p/1664282.html