Select Columns of a View

后端 未结 5 1698
我寻月下人不归
我寻月下人不归 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:19

    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 = ''
    

提交回复
热议问题