sql server get table list from column name
Today, I wanted to list down all table from column name in sql server. Sql server stores all table, column, database or etc in it's own system table. So it's easy to fetch record from it. I have given example below how to list down table list from field name. Copy and paste below code and just pass column name in this query. I hope it is helpful for you and you may like it.
select sys.tables.name from sys.objects inner join sys.tables on sys.objects.object_id = sys.tables.object_id and sys.tables.type = 'U' inner join sys.columns on sys.tables.object_id = sys.columns.object_id where sys.columns.name = 'XYZ' order by sys.tables.name