You are here: [OT] Re: stored procedure to concatenate column value sin a single cell? « MsSQL Server « IT news, forums, messages
[OT] Re: stored procedure to concatenate column value sin a single cell?

Posted by Ed Murphy on 01/18/07 19:48

haslam007@gmail.com wrote:

> Ed Murphy wrote:
>> parth wrote:
>>
>>> I want to achieve the following transformation of data using a stored
>>> procedure.
>>>
>>>
>>> Source
>>>
>>> col1 col2(varchar)
>>> -------------------------
>>> 1 1.1
>>> 1 1.2
>>> 2 2.1
>>> 2 2.2
>>> 2 2.3
>>> =================
>>>
>>> Desired Result
>>>
>>> col1 col2(varchar)
>>> --------------------------
>>> 1 1.1 | 1.2
>>> 2 2.1 | 2.2 | 2.3
>>> =====================

>> Eww. Are you sure you can't do this in the application layer? (It
>> would be simple in Crystal Reports, for instance.)

> How would i do this in Crystal?

(Don't top-post. Fixed.)

1) Group by col1

2) In the group header section, add a function "Initialize List":

Shared StringVar Col2List := "";
""

3) In the detail section, add a function "Accumulate List":

Shared StringVar Col2List;
if Col2List = ""
then Col2List := {col2}
else Col2List := Col2List + " | " + {col2};
""

and then suppress the section from printing.

4) In the group footer section, add a function "Print List":

Shared StringVar Col2List;
Col2List

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация