none
Get columns of a view RRS feed

  • Question

  • Hi all,

    Is it possible to get the columns (and preferably their types) of view? And if yes, how?

    Thanks,

    Ivan

    Monday, May 14, 2012 11:44 AM

Answers

  • Hi Cryo75,

    Welcome to MSDN Forum.

    Please refer to the T-SQL below. You can modify the 'TABLE_NAME' as the view's name which you want to query.

    use BreakAway
    SELECT COLUMN_NAME
    FROM BreakAway.INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = N'vPaymentsforPeriod';
    

    Best Regards

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Cryo75 Saturday, May 19, 2012 9:10 AM
    Tuesday, May 15, 2012 9:22 AM
    Moderator

All replies

  • Hi,

    afaik, the columns of a view are the columns of the table on which the view is based, so it would be:

    for each col as datacolumn in myview.Table.Columns debug.Print(col.Colunmname)

    debug.Print(col.DataType.ToString()) end for

    I'm talking about an ado dataview, this being an ado forum... 


    Regards, Nico




    • Edited by Nico Boey Saturday, May 19, 2012 8:14 AM
    Monday, May 14, 2012 12:42 PM
  • Hi Cryo75,

    Welcome to MSDN Forum.

    Please refer to the T-SQL below. You can modify the 'TABLE_NAME' as the view's name which you want to query.

    use BreakAway
    SELECT COLUMN_NAME
    FROM BreakAway.INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = N'vPaymentsforPeriod';
    

    Best Regards

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Cryo75 Saturday, May 19, 2012 9:10 AM
    Tuesday, May 15, 2012 9:22 AM
    Moderator
  • Hi Cryo75,

    Have you solved the issue? I look forward to hearing from you. If you have any problems, please feel free to let me know. I will do my best to help you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Saturday, May 19, 2012 6:52 AM
    Moderator