SQL 检查 是否存在 表 临时表

1.检查临时表是否存在 已有临时表#temp2

if exists(select * from tempdb..sysobjects where id =object_id('tempdb..#temp2'))
  print '#temp2表存在'else
  print '#temp2表不存在'

2.检查数据库的表是否存在

 if object_id('bukrs(you table name)') is not null
 print 'bukrs表存在'
 else
 print 'bukrs表不存在'

 

posted @ 2016-12-22 19:11  微笑代表淡定.Net  阅读(343)  评论(0编辑  收藏  举报