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 |
viniit24
Starting Member
3 Posts |
Posted - 2007-11-01 : 05:41:55
|
i have a table called Trustee with fields TrustNumber,ClientID and TrustName. here corresponding to a TrustNumber there could be more than one records. My requirement is to transfer all the rows corresponding to each distinct TrustNumber in a single row in a new table with fields say TrustNumber,ClientID1,TrustName2,ClientID2,TrustName2, ClientID3,TrustName3, and so on, maximum to 7. i had solved the problem using two cursors, but that is very time consuming( it took almost an hour to processed 58k records).Can anyone suggest a better option for this.thanks,vineet |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-01 : 05:51:09
|
can you post your table DDL ? same sample records from that table and the required result from that sample ?Also please state the version of Microsoft SQL Server that you are using. KH[spoiler]Time is always against us[/spoiler] |
 |
|
viniit24
Starting Member
3 Posts |
Posted - 2007-11-01 : 06:50:55
|
Trustee table:Trust Number ClientID TrustName040312-06 11154 Gilbert and Clemille Lai Trust 040312-06 11155 Howard and Gladys Tengan Trust040312-06 11156 Tsutomu and Frances Abe Living Trust Destination Table's fields( single row):040312-06 11154 Gilbert and Clemille Lai Trust 11155 Howard and Gladys Tengan Trust 11156 Tsutomu and Frances Abe Living Trust NULL NULL NULL NULL NULL NULL NULL NULLi m using sql server 2005 version,data type:Trust Number varchar(50)all trust name fields varchar(50)All Client ID fields intthanks,vineet |
 |
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2007-11-01 : 07:55:55
|
(Moved to the SQL Server 2005 T-SQL forum.)=================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|