Solved

How to find field exists in which table +sql server

Posted on 2011-03-11
4
655 Views
Last Modified: 2012-05-11
Hi,
I know the field exists in databse but,need to know in which table.
Any suggestions are appreciated.

Cheers
0
Comment
Question by:RIAS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Assisted Solution

by:mayank_joshi
mayank_joshi earned 250 total points
ID: 35107447
this will dispaly the table name in which the column exists:-

select OBJECT_NAME(object_id) from sys.columns where name='your_column_name'

Open in new window

0
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 35107451
Use IF EXISTS as follows:
if exists (select TheColumnName from INFORMATION_SCHEMA.Columns where Table_Name = 'YourTable')
0
 

Author Closing Comment

by:RIAS
ID: 35107457
Cheers mates!!!
0
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35107462
alternative way :-

select TABLE_NAME from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME='your_column_name'

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question