sqlserver中判断表是否存在

用户表:

if   exists   (select   *   from   sysobjects   where   xtype   =   'u'   and   id   =   object_id(N'tablename')    
  ....  

临时表:

 if exists(select * from tempdb..sysobjects where id=object_id('tempdb..##Emp2'))
      drop table ##Emp2

你可能感兴趣的:(sqlserver)