删除升级时产生的备份表

by 吕洪雨 2011.9.29 16:24

注:脚本执行有风险,对于客户正式环境请在研发指导下执行。

升级会产生很多的备份表,不但占空间还占眼睛,于是乎这个脚本产生了,如果你有特殊的需求,把红色的部分改一下就可以了,这个你懂的...

declare @table nvarchar(50)
declare @sql nvarchar(max)

DECLARE TABLES_CURSOR CURSOR FOR
select name from sys.tables where name like 'temp_%2011%'

open TABLES_CURSOR

FETCH NEXT FROM TABLES_CURSOR
into @table

WHILE @@FETCH_STATUS = 0
begin
 set @sql= 'drop table ' + @table
 
 exec(@sql)
 print @sql + '---ok'
 FETCH NEXT FROM TABLES_CURSOR
  into @table
end
CLOSE TABLES_CURSOR
DEALLOCATE TABLES_CURSOR

评论 (4) -

dongli2 wrote at 2012/2/9 14:44:29 #

好东西。。居家旅行备份省空间必备啊= =

tarot economico visa 美国 wrote at 2016/4/30 18:53:15 #

Hey, I think your blog might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, great blog!

agen bandarq terbaik indonesia 美国 wrote at 2017/5/10 2:30:46 #

My partner and I stumbled over here from a different website and thought I might check things out. I like what I see so now i'm following you. Look forward to exploring your web page again.

bandarq 美国 wrote at 2017/5/10 2:30:52 #

Hi there every one, here every one is sharing such knowledge, so it's nice to read this webpage, and I used to pay a visit this webpage daily.

添加评论



biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading


RecentComments

评论 RSS

Statistics

989 篇文章
0 个单页
652917 条评论
11 次评分
248911 次访问
访问统计开始于 2019年12月15日
平均日访问 5531 次
当前 111 人在线