欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > MSSQL教程 > sqlserver通用的删除服务器上的所有相同后缀的临时表

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:740

高端HTML5响应式企业通用网

2020-05-06   浏览:521

html5响应式外贸网站英文版

2020-05-08   浏览:510

HTML5自适应律师工作室类网

2020-04-04   浏览:504

HTML5影视传媒文化公司类网

2020-05-12   浏览:500

sqlserver通用的删除服务器上的所有相同后缀的临时表

发布时间:2020-03-19  

复制代码 代码如下:


use tempdb
if object_id('tempdb..#table') is not null drop table tempdb..#table
select name into tempdb..#table
from (select * from sysobjects where xtype='U') a where
a.name like '%test_select'

declare @table varchar(100),@count int
select @count=count(name) from tempdb..#table

while(@count>0)
begin
select top 1 @table=name from tempdb..#table

exec('
if object_id('''+@table+''') is not null drop table '+@table+'
delete from tempdb..#table where'+@table+'''
')
set @count=@count-1
end
drop table tempdb..#table


建议:尽量不要大量使用临时表,因为使用tempdb库会使系统的负载加大。