刪除數據庫中全部表,存儲過程

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)數據庫

print @tname
exec(@tname)
gotable

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)object

print @tname
exec(@tname)
goselect

相關文章
相關標籤/搜索