利用sql批量删除表,存储过程
利用sql批量删除表,存储过程。 最近用godaddy的空间,由于系统里面的表多,一个个的删除很麻烦,就网上搜集了一下解决方法。 给大家分享一下: 1.批量删除存储过程 declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where type = p open cur fetch next from cur into @procName while @@fetch_status = 0 begin if @procName <> DeleteAllProcedures exec(drop procedure + @procName) fetch next from cur into @procName end close cur deallocate cur 2,批量删除外键 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 3.批量删除表 DECLARE c2 cursor for select drop table [+name +]; from sysobjects where xtype = u open c2 declare @c2 varchar(8000) fetch next from c2 into @c2 while(@@fetch_status=0) begin exec(@c2) fetch next from c2 into @c2 end close c2 deallocate c2 --批量清除表内容: --1.禁用外键约束 DECLARE c1 cursor for select alter table [+ object_name(parent_obj) + ] nocheck 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.清除表内容 DECLARE c2 cursor for select truncate table [+name +]; from sysobjects where xtype = u open c2 declare @c2 varchar(8000) fetch next from c2 into @c2 while(@@fetch_status=0) begin exec(@c2) fetch next from c2 into @c2 end close c2 deallocate c2 --3.启用外键约束 DECLARE c1 cursor for select alter table [+ object_name(parent_obj) + ] check 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
利用sql批量删除表,存储过程的更多相关文章
- SQL 批量删除表
/*-------------------------------- 功能说明: 批量DropTable 使用说明: 使用时一定要小心,因为删选表的where条件是like所有必须保证where 后的 ...
- 在SSMS里批量删除表、存储过程等各种对象
在SSMS里批量删除表.存储过程等各种对象 以前想找批量删除表或者存储过程的方法,原来SSMS的GUI界面也可以完成 请看下图,因为这次出差的时候要删除所有的存储过程,然后重建这些存储过程 而表.函数 ...
- mssql sqlserver 批量删除所有存储过程的方法分享
转自:http://www.maomao365.com/?p=6864 摘要: 下文讲述采用sql脚本批量删除所有存储过程的方法,如下所示: 实验环境:sqlserver 2008 R2 平常使用sq ...
- sqlserver批量删除表
--批量删除表 ) DECLARE tmpCur CURSOR FOR SELECT name FROM sys.objects WHERE TYPE='U' AND name LIKE N'%_Qu ...
- SQL Server删除表信息的三种方法
1.使用DELETE实现SQL Server删除表信息 (1)删除表中的全部信息 USE student GO DELETE student --不加where条件,删除表中的所有记录 go ...
- SQL语句 删除表user 中字段name 内容重复的记录,
public class T01 { public static void main(String[] args) { int j=4; j=j+=j-=j*=j; System.out.printl ...
- postgresql批量删除表
CREATE FUNCTION del_ora_table() RETURNS void AS $$ DECLARE tmp ); DECLARE names CURSOR FOR select ta ...
- SQL批量插入表类 SqlBulkInsert
ado.net已经有了sqlBulkCopy, 但是那个用xml格式,网络传输数据量太大. 自己实现了一个,传输尽量少的字节. 性能没对比过,有需要的自己拿去测试. using System.Data ...
- SQL批量删除用户表(先删除所有外键约束,再删除所有表)
--批量删除用户表 --1.删除外键约束DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] d ...
随机推荐
- PEM文件格式详细解析
PEM文件格式存档 Author:Roson sun sunxiao@tomonline-inc.com Time:2006-4-11 1. 描述: Openssl使用PEM(RFC 1421-14 ...
- excel的常用公式
1,合并单元格 例子 B1="delete from table where id='"&A1&"';" 注意最好单元格为文本格式 1,去重复列 ...
- Tomcat在eclipse中起动成功,主页却打不开
症状: tomcat在eclipse里面能正常启动,而在浏览器中访问http://localhost:8080/不能访问,且报404错误.同时其他项目页面也不能访问. 关闭eclipse里面的tomc ...
- [Perl] Getopt 函数来接收用户参数的使用
我们在linux常常用到一个程序需要加入参数,现在了解一下perl中的有关控制参数的函数.getopt.在linux有的参数有二种形式.一种是–help,另一种是-h.也就是-和–的分别.–表示完整参 ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...
- [物理学与PDEs]第3章 磁流体力学
[物理学与PDEs]第3章第1节 等离子体 [物理学与PDEs]第3章第2节 磁流体力学方程组 2.1 考虑到导电媒质 (等离子体) 的运动对 Maxwell 方程组的修正 [物理学与PDEs]第3章 ...
- JAVA用户数据输入
数据输入 首先需要导入扫描仪 然后声明扫描仪 输出输入提示 接收用户数据的数据 输出用户数据的数据 实例: import java.util.Scanner; //导入扫描仪 public class ...
- strace命令
简介 strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核 ...
- Redis优化经验
内存管理优化 Redis Hash是value内部为一个HashMap,如果该Map的成员数比较少,则会采用类似一维线性的紧凑格式来存储该Map, 即省去了大量指针的内存开销,这个参数控制对应在red ...
- Linux Shell入门(转载)
From:http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html 从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用 ...