Store Multiple values in one Column.
-
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:
-
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:
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.
-
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:
If you're using SQL 2005 you could have a look at the PIVOT command.