删除数据库所有存储过程的SQL语句

来源:互联网 发布:淘宝个人店铺 注册商标 编辑:程序博客网 时间:2024/05/21 10:06

下面为您介绍能够一次性删除数据库所有存储过程的SQL语句,供您参考,如果您对相关的SQL语句感兴趣,不妨一看,希望能够对您有所启迪。

--/第1步**********删除所有表的外键约束*************************/

代码

DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; ' from sysobjects where xtype = 'F'open c1declare @c1 varchar(8000)fetch next from c1 into @c1while(@@fetch_status=0) begin exec(@c1) fetch next from c1 into @c1 endclose c1deallocate c1

--/第2步**********删除所有表*************************/

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)
阅读全文
0 0
原创粉丝点击