How to view the columns of a system view in SQL Server?

1

Well I come from the Oracle culture and want to learn about SQL Server. I would like to know how I see the columns of a system view, for example: I tried with

sp_help teste.INFORMATION_SCHEMA.ROUTINES

and

desc teste.INFORMATION_SCHEMA.ROUTINES

To try to visualize the columns of this view that shows the routines of the test database but did not get any success, how do I query these meta data?

    
asked by anonymous 05.08.2018 / 17:17

1 answer

2

Try it like this (I'm assuming the name of VIEW is teste ):

SELECT      AO.name AS [View Name]
        ,   AC.name AS [Column Name]
        ,   ST.name AS [Type]
FROM        sys.all_objects AO
INNER JOIN  sys.all_columns AC  ON  AC.object_id        = AO.object_id
INNER JOIN  sys.types       ST  ON  AC.system_type_id   = ST.system_type_id 
                                AND AC.user_type_id     = ST.user_type_id
WHERE       AO.type = 'V'
        AND AO.name = 'teste'
ORDER BY    AC.name
    
06.08.2018 / 10:53