因为急需删除数据库里面的所有东西,随即写了这些代码,不知道有没有人用得着,我用的是SQLServer2008R2的数据库:
declare @count int
select ROW_NUMBER() over(order by name) as rows , name into #t1 from sysobjects where xtype='p' select @count = COUNT(*) from #t1 declare @tablename varchar(80) while(@count >0) begin select @tablename = name from #t1 where rows = @count exec('drop proc dbo.' + @tablename) --这是删除存储过程的,如果是删除 表就把proc 改成table 或者view(视图),同时上面的p也要改成V(视图)或者U(表格) set @tablename = '' set @count = @count -1 end drop table #t1