Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2009
    Posts
    2

    Unanswered: Convert Query to Flat View - SQL Server 2005

    I'm hoping someone can point me to the right direction for this. I want to be able to convert my existing query which returns multiple records into a view that would look sort of like a spreadsheet.

    My query that returns something like this:

    1 Number_of_Bolts 11
    2 Number_of_Nails 325
    3 Number_of_Pins 1355

    The query itself is:

    select question_id, question_name, question_value
    from question_data d
    inner join question_dictionary i
    on d.question_id = i.question_id
    where master_id = '2111'

    Given this, how do I get it into a format where all the records are on the same row spreadsheet style and the key identifier like Number_of_Bolts is a cell header with 11 as the value underneath it? I want this be a view in SQL Server.

    Thanks for any hints you all can provide.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    How many "headers" are there?
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    George, there could be hundreds potentially.

  4. #4
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Look at PIVOT function.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Or perform the transformation in your presentation layer.
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by gvee View Post
    Or perform the transformation in your presentation layer.
    Application
    Presentation
    Session
    Transport
    Netword
    Datalink
    Physical

    Still remember this from '91-'92 when I took the Novell CNE exams, blah !

    Let's not forget the SNA Model (when IBM ruled)

    Transaction
    Presentation
    Data Flow
    Transmission
    Path control
    Data link
    Physical
    Last edited by PMASchmed; 11-05-09 at 16:10.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •