SqlServer查询数据库中所有表名,查询包含某个字段的表名

select name from sysobjects where xtype='u' --读取库中的所有表名

select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='表名') --读取指定表的所有列名

select * from sysobjects where xtype='u' AND EXISTS(select 1 from syscolumns where id=sysobjects.id AND name='Attachment') --查询包含Attachment字段的表

 

posted @ 2021-01-28 09:48  HRain  阅读(879)  评论(0)    收藏  举报