Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    8

    Unanswered: Transfer data from one table to seperate columns of another table

    We are looking at moving data from one table to another, please see the example tables below

    Code:
    Table 1
    Id               IncId           Location
    1                001              Wales
    2                001              England
    3                001              Scotland
    4                002              Wales
    5                003              England
    6                003              Scotland
    7                004              Wales
    8                004              Scotland
    We now need to get the above data into a new table
    Code:
    IncId      Wales      England     Scotland
    001         Yes         Yes          Yes
    002         Yes
    003                       Yes          Yes
    004         Yes                        Yes
    The only problem is that there is so much data in table one that the statement we created causes a memory issue. Is this possible with a loop statement and could someone help with this?

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    What statement did you used?
    If you used another statement, the memory issue may be not caused even for much data.

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please see "PIVOT" in "SQL on Fire! Part 1".

    http://www.sirdug.org/downloads/SQLonFire_1_SirDUG.pdf

Posting Permissions

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