千家信息网

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

发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,--下面以临时表#temp为例,判断它是否存在,存在就删除它IF OBJECT_ID('tempdb..#temp') is not nulldrop table #temp--方法一1if exis
千家信息网最后更新 2025年11月07日判断临时表是否存在,存在就删除
--下面以临时表#temp为例,判断它是否存在,存在就删除它IF OBJECT_ID('tempdb..#temp') is not nulldrop 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


0