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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Concantenate values from multiple rows into a single field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-17 : 08:22:33
Shannon writes "I'm working on a project that is going to require me to upload data to another agency on a weekly basis. The problem I have right now is their database design. We currently store some of the information that they are asking for in seperate tables, with multiple rows. An example would be a description. We have as single entry for an object in a table, but a seperate description table that can have multiple records. That way one of the records in description might be the dimension of the object, the next line could be the color, etc. This is not fix. Most objects have a single descriptive record, but some have up to ten, and it isn't fixed, so someone could put in a record today with 100 descriptive records.

The only way I can figure to handle this would be to write a procedure and then use a cursor to store the values for the field, so it would loop through and do something like @value = @value + @currvalue.

I would rather not use a cursor if at all possible.

Oh, I forgot to mention, the data is from a text field, so it can be huge.

Am I hopelessly screwed?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-06-17 : 09:15:29
This thread:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=15651

Has several links that have code to assemble strings together. None of them use cursors, but AFAIK none of them work with text columns, and I'm not sure they can be adapted to do so.

If the descriptions are kept in text columns, why use multiple rows for them? Text can store 2GB worth of data. And unless the descripion exceeds 8000 characters regularly, you don't even need text.

If you can post the table structures you have, some sample data, and the format you need to translate it into I'll take a crack at it.

Go to Top of Page
   

- Advertisement -