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

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

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

2020-07-25 13:16:05
字體:
供稿:網(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 name='''+@table+'''
')
set @count=@count-1
end
drop table tempdb..#table

建議:盡量不要大量使用臨時表,因?yàn)槭褂胻empdb庫會使系統(tǒng)的負(fù)載加大。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 大姚县| 栖霞市| 东乡族自治县| 顺昌县| 玛纳斯县| 宜章县| 长治市| 和顺县| 定襄县| 龙南县| 合山市| 广安市| 米脂县| 蓬溪县| 宝坻区| 吉木萨尔县| 泸定县| 古浪县| 江阴市| 巫溪县| 读书| 龙胜| 托克逊县| 嘉鱼县| 桂阳县| 固原市| 商洛市| 神农架林区| 壤塘县| 厦门市| 富裕县| 津南区| 鄂托克前旗| 清徐县| 百色市| 潮安县| 新密市| 武汉市| 堆龙德庆县| 马公市| 普定县|