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
 Transact-SQL (2000)
 Help concatenating Text columns

Author  Topic 

msimon7
Starting Member

2 Posts

Posted - 2004-04-23 : 14:45:24
Hello, I'm relatively new to SQL Server (but have been using oracle for many years) and was hoping someone could give me a hand working with text fields.

what i'm trying to do is create a summary table joining multiple tables together and put the information into a single row. the problem i'm running into is a column in a table (called comments) that has a text variable. basically for a given ID, i want to loop thru the comments table via a cursor i assume and pick up all the entries (comments) and concatenate them into one text field, seperating them by a datestamp.

for example for ID 123, that has say 3 comments (or 3 rows in the comment table) output that information into my new table that also has a text column called CommentSum. so it would be like '[01/01/2004]' + "comment 1 ...." + [01/05/2004]' + "comment 2 ...." + [01/15/2004] + "comment 3 ...."

i've read up on how you need to get the pointer of the text field for reading/updating/inserting and that you can not define a local variable as a text field in a stored procedure, but you can define an input parameter of a stored proc as a text field. this is where i'm kinda stuck at this point.

was wondering if anyone could shed a little light on how i would accomplish this and sample could would be extremely helpful.

thanks for any help, marc

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-23 : 15:15:55
Can we talk you out of this?

Why do you want to denormalize the data?



Brett

8-)
Go to Top of Page

msimon7
Starting Member

2 Posts

Posted - 2004-04-23 : 17:14:20
:) i hear you. this is for an extract of data to be dumped into another application, nothing more. the source that it is going to can only accept 1 value per column (no one-to-many relations). thanks for the reply. i'm assuming this can be done, i'm interested in learning how to....
Go to Top of Page
   

- Advertisement -