当前位置: 代码迷 >> ASP.NET >> 在已知表中查询某字段是不是存在
  详细解决方案

在已知表中查询某字段是不是存在

热度:5555   发布时间:2013-02-25 00:00:00.0
在已知表中查询某字段是否存在
已经有一个表shop,查询字段名rent31是否存在。

求代码怎么写?

------解决方案--------------------------------------------------------
select count(*) from sysobjects u, syscolumns c where u.xtype='u'
and u.name='表名' and u.id=c.id
and c.name='列名'


select count(1) from syscolumns where id = object_id('表名')
and name='列名'

两种写法都可以。。。
  相关解决方案