SQLServer 删除所有表和删除所有存储过程

1、删除所有表

use 数据库
declare @tname varchar(8000)
set @tname=''
select @tname=@tname + Name + ',' from sysobjects where xtype='U'
select @tname='drop table ' + left(@tname,len(@tname)-1)
exec(@tname)

 

2、删除所有存储过程

use 数据库
declare @tname varchar(8000)
set @tname=''
select @tname=@tname + Name + ',' from sysobjects where xtype='P'
select @tname='drop Procedure ' + left(@tname,len(@tname)-1)
exec(@tname)

 

posted @ 2014-07-01 14:53  b̶i̶n̶g̶.̶  阅读(181)  评论(0编辑  收藏  举报