select *
from tempdb.sys.objects
where 1=1
and CHARINDEX('#tmp',name)>0
select *
from tempdb.sys.columns
where 1=1
and object_id IN (
select *
from tempdb.sys.objects
where 1=1
and CHARINDEX('#tmp',name)>0) if OBJECT_ID(N'tempdb.dbo.#temp')is not null
select '存在'
if OBJECT_ID(N'tempdb..#temp')is not null
select '存在'
本文介绍了一个SQL查询脚本,用于检查并确认tempdb中的临时表(如#temp)是否存在,并通过IF语句输出结果。

被折叠的 条评论
为什么被折叠?



