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

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

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

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

[[15062]][[15063]]代码

DECLARE c1 cursor for
select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; '
from sysobjects
where xtype = 'F'
open c1
declare @c1 varchar(8000)
fetch next from c1 into @c1
while(@@fetch_status=0)
begin
exec(@c1)
fetch next from c1 into @c1
end
close c1
deallocate 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)

 

责任编辑:段燃 来源: 博客园
相关推荐

2011-06-03 10:31:14

SQL

2010-09-01 16:55:55

SQL删除连接

2010-09-03 14:14:16

SQL删除

2010-09-06 11:05:05

SQL SERVER语句

2010-09-25 15:37:38

SQL语句

2010-10-22 16:40:27

SQL TRUNCAT

2011-07-13 16:19:54

存储过程SQL Server数

2011-09-01 14:00:11

SQL Server 存储过程显示表结构

2011-08-04 12:49:31

SQL Server数重复数据

2010-04-16 13:53:23

Oracle数据库

2010-09-07 15:12:25

SQL语句优化

2023-09-05 08:40:57

删除数据库Oracle

2009-11-05 18:07:33

Oracle导出sql

2010-11-10 13:03:15

SQL Server存

2011-07-28 14:31:47

SQL Server数存储过程

2017-02-06 10:53:33

2010-09-07 11:09:33

SQL语句

2011-08-29 10:55:03

SQL Server分页存储过程优化效率分

2017-04-01 18:30:47

MySQL误删除数据库

2011-07-19 15:18:46

存储过程sql语句
点赞
收藏

51CTO技术栈公众号