sql server get table list from column name

Posted by Bharat Patel on June 11, 2010
  0 comments

Hello Friends,

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


Comments


Leave a comment

Tell us about yourself
Your Name     (required field)
Your Email Address     (required field)
Website URL      
Comment and preferences
Your Comment  
   
  Subscribe to this comment thread