Pouria Sharif
Pouria Sharif

Reputation: 166

Getting VIEW metadata from SQL Server using T-SQL

I'm trying to get description of the views on my database, and I tried joining INFORMATION_SCHEMA.VIEWS with sys.extended_properties.

Problem is that I can't find ID in INFORMATION_SCHEMA.VIEWS

Anyone know how to solve the problem?

Thanks in advance.

Upvotes: 0

Views: 5547

Answers (1)

Gottfried Lesigang
Gottfried Lesigang

Reputation: 67311

You'll get the object's id like this:

SELECT * FROM sys.objects WHERE type='v'

You might join the extended properties like this

SELECT * FROM sys.objects AS o
INNER JOIN sys.extended_properties AS ep ON ep.major_id=o.object_id;

Upvotes: 2

Related Questions