Select Columns of a View
Try this:
SELECT *FROM sys.views
This gives you the views as such - if you need the columns, use this:
SELECT * FROM sys.columnsWHERE object_id = OBJECT_ID('dbo.YourViewNameHere')
Not sure how you can do it using the INFORMATION_SCHEMA
- I never use that, since it feels rather "clunky" and unintuitive, compared to the sys
schema catalog views.
See the MSDN docs on the Catalog Views for all the details of all the views available, and what information they might contain.
INFORMATION_SCHEMA views holds metadata about objects within database. INFORMATION_SCHEMA.COLUMNS uses underlying sys tables to retrive the metadata ( check sp_helptext 'master.Information_schema.columns' ). You can use this simpler query to select column names used in any view.
SELECT col.name FROM <db_name>.sys.columns col, <db_name>.sys.views vewWHERE col.object_id = vew.object_idAND vew.name = '<view_name>'