• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 132
  • Last Modified:

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

I need a select statement that will search a database and return the table name that a specific field lives in.
0
bjbrown
Asked:
bjbrown
  • 2
1 Solution
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Something like this?
SELECT OBJECT_NAME(id)
FROM syscolumns
WHERE name='ColumnNameHere'

Open in new window

0
 
bjbrownAuthor Commented:
Exactly what I was looking for. Thank you Vitor !!!
0
 
Atdhe NuhiuCommented:
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
 
bjbrownAuthor Commented:
Darrol,

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

Brian
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now