如何在SQL Server 2008中获取所有具有名为CreatedBy
的列的表。
答案 0 :(得分:0)
在Sql Server中,您可以通过查看sys.columns
表
use DB_MAST_AERRE
select
OBJECT_SCHEMA_NAME(object_id) AS SchemaName,
object_name(object_id) AS TableName
from
sys.columns
where name = 'CreatedBy'
答案 1 :(得分:0)
use [AdventureWorks2014]
go
declare @columnname varchar(50)
set @columnname='CreatedBy'
select a.name as columnname ,b.name as tablename
from sys.columns a
inner join sys.tables b
on a.object_id=b.object_id
where a.name like '%'+@columnname+'%'