• If I assume that you could do this if you knew the names of the columns, the problem reduces to getting the names of the columns and then assembling them into the query string and executing it.

    Column names can be extracted (in their correct order) from information_schema.columns. Try running this:

    select table_name

    ,column_name

    ,ordinal_position

    ,data_type

    from information_schema.columns

    order by 1

    ,3

    Now we have to resort to dynamic SQL... There may be another way but none comes to mind.

    Put your various column names into local variables and then build your SQL string from them.

    And finally,

    Exec(@sql_string)

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.