• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 125
  • 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
 
Philip PinnellCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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