您的位置:首页 > 其它

判断临时表是否存在,存在就删除

2018-07-12 17:16 218 查看
--下面以临时表#temp为例,判断它是否存在,存在就删除它
IF OBJECT_ID('tempdb..#temp') is not null
drop table #temp

--方法一
1if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')2    drop table #tempcitys

--方法二
if object_id('tempdb..#tem') is not null
begin
print 'exists'
end
else
begin
print 'not exists'
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  临时表 存在 删除