Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 turning values within a column into values in a row

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-14 : 09:04:53
Kelly Baber writes "Is it possible to select a column from a table and then put the values into a row as either a new table, or as rows repeated within another table. For example, I have a table with a column called Name. I want to select all rows from this column then place each row into a column. It would look something like this:
>
Select name from table

> Name
> Alice
> Ray
> Dave
> Mike

Then place them into columns

> Col1 	Col2 	Col3 	Col4
> Alice Ray Dave Mike


Then for each record in an existing table, have them
repeat for each row

> Col1 	Col2 	Col3 	Col4	Col5	Col6 	Col7 Etc..
> Alice Ray Dave Mike N Y G
> Alice Ray Dave Mike G GHT Yuk
> Alice Ray Dave Mike 2 7 uuuu


In other words, I am making columns out of rows then placing them into an existing table. If it can be done, then we have to look at automating it as I have to do it 500 times.
"
   

- Advertisement -