locked
dynamiclly find the column names for particular table RRS feed

  • Question

  • Hi All,

    I want find the column names dynamically in SQL server.. that query i want use in my code.

    Example: x table have columns a1,a2,a3

    but i want find dynamically through query

    Regards

    Ram

    Wednesday, September 1, 2010 2:09 PM

Answers

  • Yes, just use a query like this.

     

    select TABLE_NAME, COLUMN_NAME

    from INFORMATION_SCHEMA.COLUMNS

    order by TABLE_NAME, ORDINAL_POSITION

     

    Add a where clause to filter out specific tables.

     

    - Raoul

    Wednesday, September 1, 2010 8:01 PM