Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Store Multiple values in one Column.

Store Multiple values in one Column.

Scheduled Pinned Locked Moved Database
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astrovirgin
    wrote on last edited by
    #1

    Hi, So the problem is I have one table which contains 1 column and 3 rows. Like This::: Description ----------- HR PM Faculty Now what I want is to store these columns in another table in one row. Like:::: Staff ------ HR,PM,Faculty. Please Help me to this and Don't give any other suggestion to complete this task. I just want the same. Thanks in Advance. :doh:

    H P 2 Replies Last reply
    0
    • A astrovirgin

      Hi, So the problem is I have one table which contains 1 column and 3 rows. Like This::: Description ----------- HR PM Faculty Now what I want is to store these columns in another table in one row. Like:::: Staff ------ HR,PM,Faculty. Please Help me to this and Don't give any other suggestion to complete this task. I just want the same. Thanks in Advance. :doh:

      H Offline
      H Offline
      HemJoshi
      wrote on last edited by
      #2

      1. First Create a temp tabel. 2. Then count the now of row in the first table. 3. use loop while < rownum Then add the column in the temp table using the below dynamic query ( set @colname = @colname + ' ALTER TABLE #Temp ADD col'+ cast(@count as varchar(10)) + ' decimal(10, 2) NULL ' exec(@colname) ) 4. using cursers update the different column values.

      1 Reply Last reply
      0
      • A astrovirgin

        Hi, So the problem is I have one table which contains 1 column and 3 rows. Like This::: Description ----------- HR PM Faculty Now what I want is to store these columns in another table in one row. Like:::: Staff ------ HR,PM,Faculty. Please Help me to this and Don't give any other suggestion to complete this task. I just want the same. Thanks in Advance. :doh:

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        If you're using SQL 2005 you could have a look at the PIVOT command.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups