快速删除DiscuzNT论坛数据表和存储过程
来源:本站原创|时间:2020-01-11|栏目:discuz|点击: 次
本来想一个一个删除的,打开数据库一看那么多的表和存储过程,就放弃这种笨办法了,于是决定用SQL语句来搞定。代码如下:
复制代码
代码如下:-----------------------------删除数据表---------------------
DECLARE @au_lname VARCHAR(40),@SQLString NVARCHAR(500)
DECLARE tb CURSOR FOR
SELECT name FROM sysobjects WHERE xtype='U' and name like 'dnt%'
OPEN tb
-- Perform the FIRST FETCH.
FETCH NEXT FROM tb INTO @au_lname
-- CHECK @@FETCH_STATUS TO see IF there ARE ANY more ROWS TO FETCH.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This IS executed AS long AS the previous FETCH succeeds.
FETCH NEXT FROM tb INTO @au_lname
SET @SQLString='DROP TABLE '+ @au_lname
EXEC sp_executesql @SQLString
--DROP TABLE @au_lname
END
CLOSE tb
DEALLOCATE tb
GO
-----------------------------删除存储过程---------------------
DECLARE @au_lname VARCHAR(40),@SQLString NVARCHAR(500)
DECLARE tb CURSOR FOR
SELECT name FROM sysobjects WHERE xtype='p' and name like 'dnt%'
OPEN tb
-- Perform the FIRST FETCH.
FETCH NEXT FROM tb INTO @au_lname
-- CHECK @@FETCH_STATUS TO see IF there ARE ANY more ROWS TO FETCH.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This IS executed AS long AS the previous FETCH succeeds.
FETCH NEXT FROM tb INTO @au_lname
SET @SQLString='DROP PROCEDURE '+ @au_lname
EXEC sp_executesql @SQLString
--DROP TABLE @au_lname
END
CLOSE tb
DEALLOCATE tb
GO
您可能感兴趣的文章
阅读排行
本栏相关
- 01-11Discuz! 6.1.0 图文安装教程
- 01-11Discuz! 6.0.0到Discuz! 7.0.0升级教程
- 01-11Discuz!7.0邀请注册功能详解
- 01-11DISCUZ!论坛标签SEO优化
- 01-11Discuz!在论坛主题中快速插入UCHome相册
- 01-11教您为Discuz!论坛轻松更换风格
- 01-11Discuz论坛的WAP功能在手机上使用感爱
- 01-11Discuz! 积分策略向导功能详解
- 01-11Discuz!7.0论坛帮助功能详解
- 01-11安装Discuz!7.0.0 的方法与图文教程
随机阅读
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10SublimeText编译C开发环境设置
- 04-02jquery与jsp,用jquery
- 01-10delphi制作wav文件的方法
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-11ajax实现页面的局部加载
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-10C#中split用法实例总结