i want table name basis on column name.

Answer Posted / bobby

select * from information_schema.columns where
column_name='orderid'

The above query is used to find all the tables and views in
the Database which contain ‘orderId’ as column name.

But to find only the tables in the Database which
contain ‘orderId’ as column name, use the below query.


select col.table_name from information_schema.columns Col
join information_schema.tables Tab
on col.table_name=tab.table_name and
col.column_name='orderId'and tab.table_type='Base Table'

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Detail about query optimizer?

799


What happens to a statement batch if there is a compilation error?

698


What methods do you follow to protect from sql injection attack?

702


Can we insert data into a view?

825


What are Row versions of DataRow?

784






Explain how dts is used to extract, transform and consolidate data?

764


How to divide query output into multiple groups with the group by clause in ms sql server?

744


What part does database design plays a role in performance of an sql server-based application?

718


What are the purpose of Normalisation?

796


what is a join and explain different types of joins? : Sql server database administration

711


Explain having clause?

727


What are sql server functions?

678


How much space does sql server 2016 take?

726


How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

758


how can you attach more than 20 ldf files in sql server

1742