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 three ways you can use an identity value inside a trigger? Why would you prefer one way over another?

544


Define tool Manage Statistics in SQL Server 2000 query ?

524


What are the advantages of partitioning?

636


Explain indexing and what are the advantages of it?

520


What are the main sources of data?

588






How to recreate an existing index in ms sql server?

542


Write a program to fetch first 10 records from a file?

598


How to change a login name in ms sql server?

556


What are “lock” hints?

585


What is the difference between Stored Procedures and triggers?

568


What are the different types of subquery?

608


How to change server name in sql server?

554


How to bind a view to the schema of the underlying tables?

582


Sql server reporting services vs. Crystal reports.

96


What do you understand by SQL*Net?

611