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 |
|
matt_calhoon
Posting Yak Master
235 Posts |
Posted - 2006-09-26 : 04:31:06
|
| Hi there,I have a table with 2 fields. CATEGORY and DESCRIPTION. IF I run a query:Select CATEGORYID, DESCRIPTION from mytableit will return:33, 'test'33, 'another test'33, '3rd test'34, 'blah blah'34, 'etc etc'is it possible to write a query which will group the results (by the categoryid) but append the data in the description. i.e.return something like33, 'test<br>another test<br>3rd test'34, 'blah blah<br>etc etc' |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-26 : 08:33:29
|
| Note that if the concatenated string exceeds 8000 characters, you have to use more than one variable. If you use front end application, do the concatenation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-09-26 : 09:15:35
|
| Sounds like you are trying to format your data with SQL. My advice is to return the raw data as is and let your client application (in this case, a web page I am guessing) do the formatting. It is often much easier and more efficient to do it that way.Let us know which web application you are using (i.e., ASP.NET ?) and how you are trying to display the data and we should be able to help you. Also, as Madhivanan says, the other problem with doing this in T-SQL is that you run into the 8000 varchar limit.- Jeff |
 |
|
|
|
|
|
|
|