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 |
|
Incognito
Starting Member
49 Posts |
Posted - 2002-01-17 : 03:18:17
|
| I have one table which looks like:ID, Segment, Data1 0 Test11 1 Test21 2 Test3I want to combine the records so I get:ID, Data1 Test1 Test2 Test3I tried the next: Join, Union, '+' but i couldnt write the right query.Can someone help me to write it good?Thnx for your helpGokhan! |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
Posted - 2002-01-17 : 05:14:05
|
Something like this will work: DECLARE @data varchar(1000)SELECT @data = COALESCE(@data + ''''',''''','(''''') + CAST(RTRIM(data) as varchar(5))+ '' FROM TBL_NAMESELECT @data = @data + ''''')'You will need to play with the '''' and possible do some grouping depending on what your data looks like. This is what I use to construct strings to send as pass-though queries to Oracle. |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-01-17 : 05:31:23
|
| this problem has appeared here before....look for articles on CSV....(you just happen to have "spaces" instead of the comma's as your seperator)I think there is even A FAQ on it.... |
 |
|
|
Incognito
Starting Member
49 Posts |
Posted - 2002-01-17 : 06:44:00
|
| Thnx for the answers.I checked the CSV "section" but couldnt understood much. I want to wright a very simple VIEW which gets the records together.If you can give me more info It would be great.ThnxGokhan |
 |
|
|
smccreadie
Aged Yak Warrior
505 Posts |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-17 : 07:55:58
|
How about Dynamic Cross tab artilce by Rob(My entry point to Sqlteam .http://www.sqlteam.com/item.asp?ItemID=2955HTH----------------------------------"True love stories don't have endings." |
 |
|
|
|
|
|