文章摘要:SQLServer2008/2012/2014 删除所有表视图存储过程 -------------------删除所有的表------------------- use xuwenbin111 --/第1步**********删除所有表的外键约束*************************/ DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; ' from sysobjects where xtype = 'F'
SQLServer2008/2012/2014 删除所有表视图存储过程
发布时间:2022-03-23 作者:沈川超 分类: SQLserver
SQLServer2008/2012/2014 删除所有表视图存储过程
-------------------删除所有的表-------------------
use xuwenbin111
--/第1步**********删除所有表的外键约束*************************/
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
GO
--/第2步**********删除所有表*************************/
Go
declare @sql varchar(8000)
while (select count(*) from sysobjects where type='U')>0
begin
SELECT @sql='drop table ' + name
FROM sysobjects
WHERE (type = 'U')
ORDER BY 'drop table ' + name
exec(@sql)
end
-------------------删除所有的视图-------------------
use xuwenbin111
GO
declare @sql varchar(8000)
while (select count(*) from sysobjects where type='V')>0
begin
SELECT @sql='drop view ' + name
FROM sysobjects
WHERE (type = 'V')
ORDER BY 'drop view ' + name
exec(@sql)
end
-------------------删除所有的存储过程-------------------
use xuwenbin111
GO
declare @sql varchar(8000)
while (select count(*) from sysobjects where type='P')>0
begin
SELECT @sql='drop proc ' + name
FROM sysobjects
WHERE (type = 'P')
ORDER BY 'drop table ' + name
exec(@sql)
end
点击排行
标签云
-
C#
seo
SQLserver
IIS
.NET
SSL
程序员
VS
编程语言
https
微信小程序
jQuery
服务器
个人博客
网站关键词排名
301
.net8
http
KOL
C#集合
.NET框架
命名空间
面向对象编程
异常处理
异步编程
设计模式
编程学习网站
百度分享js
关键词研究工具
网页加载速度
外部链接优化
异步加载
snv
腾讯元器
AI智能体
C#接口
装潢设计
响应式
自动备份
个人网站
WPF
数据库优化
winform
UI
编程
Ngrok
内网穿透
开源框架
NanUI
网站
清明节
html
生成img
nginx
签到
2023跨年
快捷方式
标签打印
icon图标
博客模板
Web前端框架
JavaScript
TortoiseSVN
VS2019
数据库自动同步工具
Serv-U
.NETCore
微信接口
数组去重
404页面
保存图片
QQ
幸福
鸡汤
小沈子
超实用工具箱
Layui
51劳动节
C#面试题
疫情
数据库
Queue队列
网页
挖呀挖