sql server 检索包含指定字段的表名的sql语句

来源:互联网 发布:长城软件客服电话 编辑:程序博客网 时间:2024/05/20 12:20

 

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 ('指定字段一','指定字段一')

 

原创粉丝点击