if object_id('tempdb..#temp') is not null print 'exists!' else print 'not exists!'if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fa_accjc]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 用类似的办法,不过,临时表的作用域是局部的。会自动消除。
USE TMPDBselect * from sysobjects where type='u' and name like '#'+@临时表名+'[_]%'
USE TMPDBif exists(select * from sysobjects where type='u' and name like '#'+@临时表名+'[_]%') print 'exist'
if exists (select * from tempdb..sysobjects where name like '#你的表名%')
print 'exists!'
else
print 'not exists!'if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fa_accjc]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
用类似的办法,不过,临时表的作用域是局部的。会自动消除。
print 'exist'