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
Solved

I need a select statement that will search a database and return the tablename that a specific field lives in.

Posted on 2015-01-12
4
110 Views
Last Modified: 2015-01-12
I need a select statement that will search a database and return the table name that a specific field lives in.
0
Comment
Question by:bjbrown
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40544584
Something like this?
SELECT OBJECT_NAME(id)
FROM syscolumns
WHERE name='ColumnNameHere'

Open in new window

0
 

Author Comment

by:bjbrown
ID: 40544598
Exactly what I was looking for. Thank you Vitor !!!
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 40544605
Select
  O.name objectName
from sys.columns C
inner join sys.objects O
  ON C.object_id=O.object_id
where C.name ='yiurcolumnname'
0
 

Author Comment

by:bjbrown
ID: 40544659
Darrol,

This select statement worked as well, thank you for your submission.

Brian
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OSQL to execute sql command 26 24
SQL Activity Monitor detail 2 28
SQL Recursion schedule 13 16
SQL Error when trigger fires in SQL Server 2008 R2 6 16
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

829 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