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

What are the steps you will take to improve the performance of a poor performing query?

601


How to use group functions in the select clause in ms sql server?

540


What is an inner join?

530


you notice that the transaction log on one of your databases is over 4gb the size of the data file is 2mb what could cause this situation, and how can you fix it? : Sql server administration

548


what is a major difference between sql server 6.5 and 7.0 platform wise? : Sql server database administration

501






Indexes are updated automatically is the full-text index also updated automatically?

629


What is the order by used for?

625


How can I track the changes or identify the latest insert-update-delete from a table?

542


What is xdr?

570


How can I check if a view exists in a sql server database?

567


What are the approximate numeric data types?

537


Can a cursor be updated? If yes, how you can protect which columns are updated?

523


How can you set the threshold at which sql server will generate keysets asynchronously?

565


how can you check the level of fragmentation on a table? : Sql server administration

542


What is the difference between lock, block and deadlock? : sql server database administration

572