select a.name as colNm,a.id as colId,b.name as tabNm,b.id as tabId
from syscolumns a, sysobjects b
where a.id=b.id and b.xtype='U' and a.name in ('指定字段一','指定字段一')
注解:
select * from syscolumns where id=object_id('表名')
以上是检索表名的所有字段的名称
select * from sysobjects where xtype='U' and category=0
以上是检索相应用户表的方法
对于本问题的要求中更简单的处理方式是:
select table_name,column_name,data_type
from information_schema.columns
where column_name in ('指定字段一','指定字段一')

本文介绍了一种使用SQL从特定表中检索指定字段信息的方法,并提供了两种不同的查询方式,一种是利用syscolumns和sysobjects视图,另一种是通过information_schema.columns进行更为简便的操作。
2000

被折叠的 条评论
为什么被折叠?



