利用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 ...
随机推荐
- Angular学习(8)- directive
<!DOCTYPE html> <html ng-app="MyApp"> <head> <title>Study 9</ti ...
- Python-While刷博爬虫
仅用于测试 #!/usr/bin/python import webbrowser as web import time import os url = 'www.abc.com' while Tru ...
- android学习笔记15——Galley
Gallery==>画廊视图 Gallery和Spinnery父类相同——AbsSpinner,表明Garrey和Spinner都是一个列表框. 两者之间的区别是:Spinner显示的是一个垂直 ...
- linux 屏幕亮度调节
Brightness sudo gedit /etc/default/grub find this line : GRUB_CMSLINE_LINUX_DEFAULT="quiet ...
- 关于 xcode 工程编译报错 undefined symbol _res_9_init的解决办法
将libresolv.dylib 添加到工程引用中(通过build phases中).补充: _res_9_init定义在resolv.h中,可以参考http://www.opensource. ...
- 黄聪:PHP 免费获取手机号码归属地(转)
一.淘宝网API API地址: http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15850781443 参数: tel:手机号码 返回 ...
- 黄聪:wordpress源码解析-数据库表结构(转)
如果是一个普通的用户,不需要了解wordpress数据库的结构.但是,如果你正在写一个插件,你应该会对wordpress如何处理它的数据和关系感兴趣.如果你已经尝试使用已经存在的wordpress a ...
- [物理学与PDEs]第4章习题参考解答
[物理学与PDEs]第4章习题1 反应力学方程组形式的化约 - 动量方程与未燃流体质量平衡方程 [物理学与PDEs]第4章习题2 反应力学方程组形式的化约 - 能量守恒方程 [物理学与PDEs]第4章 ...
- 对CSS中的Position属性的一些深入探讨
转:http://www.cnblogs.com/coffeedeveloper/p/3145790.html Position属性 Position的属性值共有四个static.relative.a ...
- [经验总结]利用xlstproc处理XSLT的makefile
转自:http://blog.csdn.net/thinkhy/article/details/5343739 # For XSLT PARSE = xsltproc SRC = main.xml S ...