sqlserver 搜索一个库中 含有某个字段的表

USE 数据库

select
[name] from sysobjects where id in(select id from syscolumns Where name='待查询的字段名称')

延伸:查询某个表中,某个字段的类型

select a.name as [column],b.name,b.length as TYPE from syscolumns a,systypes b where a.id=object_id('CasesAttachment') and a.xtype=b.xtype and a.name='Attachment'

延伸:查询某个库中,某个字段所有表中的类型SQL

select 'select a.name as [column],b.name,b.length as TYPE from syscolumns a,systypes b where a.id=object_id('''+[name]+''') and a.xtype=b.xtype and a.name=''Attachment''' from  sysobjects 
where id in(select id from  syscolumns Where name='Attachment')
原文地址:https://www.cnblogs.com/challengesoflife/p/11080907.html