Friday, March 9, 2012

Getting Names of Tables and Fields

Hi All,

I need to get the names of tables and fields (or atleast the fields) from a database. Is there a query I can use that will return what all the db's tables and those tables fields are?

Thanks

LeeHere is the query:


SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

SELECT INFORMATION_SCHEMA.COLUMNS.column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tableName'

Hope it helps.|||Cool, thanks. Is there an easy way to get all the foreign keys for a database?

I should have specified, SQL 2000.

Thanks

Lee|||If I remember right, you need join three information schema views to find all the foreign keys in a database, I am not aware if there is more easy to do it. If you need it I will find the query and post here.

No comments:

Post a Comment