Select Columns of a View
information_schema.columns.Table_name (at least under Sql Server 2000) includes views, so just use
SELECT * FROM information_schema.columns WHERE table_name = 'VIEW_NAME'
Try this:
SELECT *
FROM sys.views
This gives you the views as such - if you need the columns, use this:
SELECT *
FROM sys.columns
WHERE 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.
I found this way working for views (SQL 2017). I was not able to get data from information_schema.columns
and sys.columns
:
SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('<view_name>')