如何判断表中某一字段是否存在?

如何判断表中某一字段是否存在?
从系统表中查找,在sysobjects表中查到对象的id,根据id到syscolumns中查找字段。比如你要找到一个test表的所有字段名:  
  select   name   from   syscolumns   where   id   in(select   id   from   sysobjects   where   name='test')    

if   exists   (select   *   from   syscolumns   where   id=object_id('TABLE1')   and   name='FIELD1')  
print   'exists'
posted @ 2006-05-10 14:30  斌哥  阅读(3983)  评论(2编辑  收藏  举报