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表不存在'
原文地址:https://www.cnblogs.com/DONET-LC/p/6212525.html