0

The SP_HELP procedures produces multiple subsets of data and I would only like to have the columns information from that. Is there a way to maybe write a query using sp_help to just pull out that information.

I need to do this to build a metadata database and maintain it on a weekly basis. Any help is appreciated.

Thanks, RV.

rvphx
  • 2,324
  • 6
  • 40
  • 69

2 Answers2

3

The information you want can be found with:

select * from sys.columns

However, it can be difficult to navigate using just that table. I like to query the schema, tables, and columns views for this.

select
    schemas.name as [schema]
    ,tables.name as [table]
    ,columns.*
from sys.schemas
join sys.tables on
    schemas.schema_id = tables.schema_id
join sys.columns on
    tables.object_id = columns.object_id

You can get more information here.

Andrew O'Brien
  • 1,793
  • 1
  • 12
  • 24
0
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'SchemaName'
      AND TABLE_NAME = 'TableName'

This should work.