if exists(
   select 1 from sys.systable 
   where table_name='New_CMD'
     and table_type in ('BASE', 'GBL TEMP')
) then
    drop table New_CMD
end if;在用PowerDesigner建表的时候在前面会加上上面的SQL语句,意思是检测有没有这个表,如果有的话删除,但是为什会报错???

解决方案 »

  1.   

    我的是这样的
    if exists (select 1
                from  sysobjects
               where  id = object_id('driver_hire_info')
                and   type = 'U')
       drop table driver_hire_info
    go
      

  2.   

    if exists(
       select 1 from sys.systable 
       where table_name='New_CMD'
         and table_type in ('BASE', 'GBL TEMP')
    )     drop table New_CMD