标签:
本文来自:http://www.cnblogs.com/yjss/articles/2065664.html
1.删除表
use 数据库名 declare mycur cursor local for select [name] from dbo.sysobjects where xtype=‘U‘ declare @name varchar(100) OPEN mycur FETCH NEXT from mycur into @name WHILE @@FETCH_STATUS = 0 BEGIN exec(‘drop table ‘ + @name) FETCH NEXT from mycur into @name END CLOSE mycur
2.删除视图
use 数据库名 declare mycur cursor local for select [name] from dbo.sysobjects where xtype=‘V‘ declare @name varchar(100) OPEN mycur FETCH NEXT from mycur into @name WHILE @@FETCH_STATUS = 0 BEGIN exec(‘drop VIEW ‘ + @name) FETCH NEXT from mycur into @name END CLOSE mycur
3.删除存储过程
use 数据库名 declare mycur cursor local for select [name] from dbo.sysobjects where xtype=‘P‘ declare @name varchar(100) OPEN mycur FETCH NEXT from mycur into @name WHILE @@FETCH_STATUS = 0 BEGIN exec(‘drop PROCEDURE ‘ + @name) FETCH NEXT from mycur into @name END CLOSE mycur
标签:
原文地址:http://www.cnblogs.com/jt789/p/5558236.html