Solved

How to find field exists in which table +sql server

Posted on 2011-03-11
4
649 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
  • 2
4 Comments
 
LVL 9

Assisted Solution

by:mayank_joshi
mayank_joshi earned 250 total points
Comment Utility
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
Comment Utility
Use IF EXISTS as follows:
if exists (select TheColumnName from INFORMATION_SCHEMA.Columns where Table_Name = 'YourTable')
0
 

Author Closing Comment

by:RIAS
Comment Utility
Cheers mates!!!
0
 
LVL 9

Expert Comment

by:mayank_joshi
Comment Utility
alternative way :-

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

Open in new window

0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Backup & Restore 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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now