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

posted @ 2009-05-29 10:24  杨子宜  阅读(309)  评论(1编辑  收藏  举报