select '' as bynd,'' as bysj from bos_mod a 
where not exists(select * from sysobjects b inner join syscolumns c on c.id = b.id where b.id = object_id('table_name') and c.name in ('bynd','bysj'))
union
select  bynd,bysj from bos_mod a 
where exists(select * from sysobjects b inner join syscolumns c on c.id = b.id where b.id = object_id('table_name') and c.name in('bynd','bysj'))
试试这个

解决方案 »

  1.   

    刚刚写错了,重新发一个
    select '' as bynd,'' as bysj from table_name a 
    where not exists(select * from sysobjects b inner join syscolumns c on c.id = b.id where b.id = object_id('table_name') and c.name in ('bynd','bysj'))
    union
    select  bynd,bysj from table_name a 
    where exists(select * from sysobjects b inner join syscolumns c on c.id = b.id where b.id = object_id('table_name') and c.name in('bynd','bysj'))
      

  2.   

    通过sysobjects和syscolumns的ID查就可以了!