如题所述
1ãå¤ææ°æ®è¡¨æ¯å¦åå¨
æ¹æ³ä¸ï¼
use yourdb;go
if object_id(N'tablename',N'U') is not null
print 'åå¨'
else
print 'ä¸åå¨'
ä¾å¦ï¼
goif object_id(N'TEMP_TBL',N'U') is not null
print 'åå¨'
else
print 'ä¸åå¨'
æ¹æ³äºï¼
USE [å®ä¾å]GO
IF EXISTS (SELECT * FROM dbo.SysObjects WHERE ID = object_id(N'[表å]') AND OBJECTPROPERTY(ID, 'IsTable') = 1)
PRINT 'åå¨'
ELSE
PRINT'ä¸åå¨'
ä¾å¦ï¼
goIF EXISTS (SELECT * FROM dbo.SysObjects WHERE ID = object_id(N'TEMP_TBL') AND OBJECTPROPERTY(ID, 'IsTable') = 1)
PRINT 'åå¨'
ELSE
PRINT'ä¸åå¨'
2ã临æ¶è¡¨æ¯å¦åå¨ï¼
æ¹æ³ä¸ï¼
goif exists(select * from tempdb..sysobjects where id=object_id('tempdb..##TEMP_TBL'))
PRINT 'åå¨'
ELSE
PRINT'ä¸åå¨'
æ¹æ³äºï¼
goif exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#TEMP_TBL') and type='U')
PRINT 'åå¨'
ELSE
PRINT'ä¸åå¨'
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-03-15
if然后什么来着