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.
Author |
Topic |
A-Man
Starting Member
1 Post |
Posted - 2011-07-26 : 00:37:45
|
Hi, I am using SQL Server 2005. I have a table with three columns like thisa --- 1 --- Aa --- 2 --- Ab --- 1 --- Bb --- 2 --- Bb --- 3 --- BI would like to insert it into another table asa --- 1,2 --- Ab --- 1,2,3 --- BAny suggestions please. |
|
sayan751
Starting Member
4 Posts |
Posted - 2011-07-26 : 01:02:02
|
You can make use of a cursor, that will concat the value of second col provided the first and third col value is same in consecutive row and insert the newly constructed row in a table, if the value is not same then break the loop and start constructing a new row.Hope that will help! |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2011-07-26 : 09:20:15
|
search the forum for "FOR XML". There are some examples to do the rows to columns and from there you should be able to work out the insert |
|
|
|
|
|