Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Find a field name within database structure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-17 : 08:25:59
James Simonetta writes "I would like to know if there is a way to search through a SQL 2000 database to look for a particular field. I don't want search the data rather all the tables that exist. For example I need to know where 'lentid' field is what is the table name and how many tables have this field?

So an expected result would be field 'lentid' is found in table 1, table23 and so on...

Thank you for your time.
Regards,
James Simonetta."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-02-17 : 08:27:15
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE 'lentid%'

There's a procedure here that does this, it's a little more compact to use:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32319

Look in Books Online for the "INFORMATION_SCHEMA" views, they're extremely handy for providing information about the database.
Go to Top of Page
   

- Advertisement -