Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to find field exists in which table +sql server

Posted on 2011-03-11
4
Medium Priority
?
658 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 1000 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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