Select Columns of a View

后端 未结 5 1691
我寻月下人不归
我寻月下人不归 2021-02-11 17:11

I\'m attempting to select the column names of a view in a similar way as selecting from information_schema.columns.

I can\'t seem to find a wa

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-11 17:45

    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.

提交回复
热议问题