国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > SQL Server > 正文

sqlserver通用的刪除服務(wù)器上的所有相同后綴的臨時表

2024-08-31 00:57:20
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


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庫會使系統(tǒng)的負(fù)載加大。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 盐津县| 合山市| 昭觉县| 福泉市| 易门县| 安龙县| 兰坪| 基隆市| 民和| 柘荣县| 襄城县| 和硕县| 博野县| 通江县| 邵阳县| 德昌县| 古蔺县| 樟树市| 瓦房店市| 巴林左旗| 兴仁县| 上饶市| 陇南市| 阜宁县| 荔波县| 博湖县| 台东市| 孙吴县| 隆昌县| 英吉沙县| 滁州市| 会昌县| 深圳市| 南充市| 新沂市| 肥乡县| 海淀区| 江山市| 武功县| 河南省| 纳雍县|