1 create table #TEMP_TBL 2 ( 3 ID INT 4 ) 5 --检验临时表是否存在 6 --方法1: 7 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TEMP_TBL')) 8 PRINT '存在' 9 --select * from tempdb..sysobjects where id=object_id('tempdb..#TEMP_TBL') 10 ELSE 11 PRINT'不存在' 12 13 --方法2: 14 15 if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#TEMP_TBL') and type='U') 16 PRINT '存在' 17 ELSE 18 PRINT'不存在' 19 20 SELECT COUNT(*) FROM [tempdb].dbo.sysobjects 21 22 select * from tempdb..sysobjects