Hi All,
I am trying to use cursor to concatenate data from multiple fields into one. Let me try to explain a little more. I have two tables - Header table and Comments table. Header table ID can have multiple comments sequences which in turn can have multiple comments. Makes sense.. no. here is some data to make it a little more clear.
Header table stores the hdr_ID and the top sequence_number. While the comments table stores all the sequences and comments for each sequence.
Header Table
hdr_ID sequence_number
1----------2
2----------3
Comments table
hdr_ID sequence_number comments
1----------1------------comment1
1----------1------------comment2
1----------2------------comment1
1----------2------------comment2
1----------2------------comment3
2----------1------------aaa
2----------2------------aaa
2----------2------------bbb
2----------2------------ccc
2----------3------------aaa
RESULT
hdr_ID sequence_number comments
1----------1------------comment1 comment2
1----------2------------comment1 comment2 comment3
2----------1------------aaa
2----------2------------aaa bbb ccc
2----------3------------aaa
How can I do this using a cursor. It's driving me nuts?
Thanks!
I am trying to use cursor to concatenate data from multiple fields into one. Let me try to explain a little more. I have two tables - Header table and Comments table. Header table ID can have multiple comments sequences which in turn can have multiple comments. Makes sense.. no. here is some data to make it a little more clear.
Header table stores the hdr_ID and the top sequence_number. While the comments table stores all the sequences and comments for each sequence.
Header Table
hdr_ID sequence_number
1----------2
2----------3
Comments table
hdr_ID sequence_number comments
1----------1------------comment1
1----------1------------comment2
1----------2------------comment1
1----------2------------comment2
1----------2------------comment3
2----------1------------aaa
2----------2------------aaa
2----------2------------bbb
2----------2------------ccc
2----------3------------aaa
RESULT
hdr_ID sequence_number comments
1----------1------------comment1 comment2
1----------2------------comment1 comment2 comment3
2----------1------------aaa
2----------2------------aaa bbb ccc
2----------3------------aaa
How can I do this using a cursor. It's driving me nuts?
Thanks!