Solved

How to find field exists in which table +sql server

Posted on 2011-03-11
4
651 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2 comma seperated list - SQL Server 12 40
How to query LOCK_ESCALATION 4 41
Help  needed 3 23
Find results from sql within a time span 11 30
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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