Presenting rows of data horizontally

  • Heslous - Friday, July 6, 2018 6:17 AM

    Hi Thom
    i do not see the Jeff's  link you talk about

    Jeff Moden - Thursday, June 28, 2012 12:48 PM

    Since there are an unknown number of potential columns, the following article tells you how to do it.http://www.sqlservercentral.com/articles/Crosstab/65048/If you'd like a coded answer, it would be helpful if the data you presented were in a readily consumable format. Please see the first link in my signature line below for how to do that properly.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Friday, July 6, 2018 4:49 AM

    Heslous - Friday, July 6, 2018 4:26 AM

    Hi everyone i have a very request regarding displaying rows in horizontal i want the columns name of a SQL server table displayed horizontally like following My query :
    NB AFPO is the name of the table i want to display columns  name from
    Also, i have a lot of tables to get the columns name displayed in Horizontal  so help would be appreciated

    My query: 
    select column_id, name from sys.all_columns where object_id = OBJECT_ID(N'AFPO') order by column_id

    displays :
    column_id    name
    1                  POSNR
    2                  MANDT
    3                  AUFNR
    4                  KDAUF

    And i want this to be displayed this way :

    column_id    1            2            3           4
    name           POSNR MANDT AUFNR KDAUF

    and no way to find out how to achieve that. Could you help me?

    6 year old topic 😉

    As for how to do this, have you had a look at the article that Jeff linked above? It should greatly help you get what you're after. Have a read and try yourself; if you get stuck please do post what you've tried so we can help you further.

    attahced is something that i created to do exactly that

    ***The first step is always the hardest *******

  • SGT_squeequal - Monday, July 9, 2018 2:52 AM

    attahced is something that i created to do exactly that

    You've not attached anything.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Monday, July 9, 2018 3:33 AM

    SGT_squeequal - Monday, July 9, 2018 2:52 AM

    attahced is something that i created to do exactly that

    You've not attached anything.

    sorry just noticed that .sql was not in the approved list see attached

    ***The first step is always the hardest *******

  • SGT_squeequal - Monday, July 9, 2018 5:28 AM

    sorry just noticed that .sql was not in the approved list

    Probably because you can put SQL straight into your post. People are less inclined to download files from strangers. 🙂

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 5 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic. Login to reply