how to enumerate all table with a column name in sqlserver db?This returns all objects with a given column name:
--------------
declare @.SearchColumn varchar(50)
set @.SearchColumn = 'Database_ID'
select sysobjects.name as ObjectName,
sysobjects.xtype as ObjectType
from sysobjects
inner join syscolumns on sysobjects.id = syscolumns.id
where syscolumns.name = @.SearchColumn
--------------
If you want just tables, filter for sysobjects.xtype = 'U'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment