Saturday, February 25, 2012

attribute search in a database

Hi guys,

I'm trying to find some attributes within a database I'm working with. I'm working with SQL Server 2000, and I'm trying to find table which have a certain attribute in them. for example, If I want to see tables from my database which have an attribute called 'home_address', what would the query be? Or is there an inbuilt function in SQL Server 2000 which allows me to search this?

Thank you!

Smile

You can query the syscolumns table directly.


SELECT object_name(id) AS objectname
FROM syscolumns
WHERE name = 'Home_Address'

HTH!

|||

Or have a look at INFORMATION_SCHEMA.columns view.

Code Snippet

SELECT * FROM INFORMATION_SCHEMA.columns WHERE COLUMN_NAME = 'Home_Address'

|||

Of course. A much better suggstion that directly accessing the system tables.

Nice one!

No comments:

Post a Comment