Select Columns of a View

后端 未结 4 1204
我寻月下人不归
我寻月下人不归 2021-02-11 17:18

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

4条回答
  •  后悔当初
    2021-02-11 17:36

    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 .sys.columns col, .sys.views vew
    WHERE col.object_id = vew.object_id
    AND vew.name = ''
    

提交回复
热议问题