cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate Data in One column

Former Member
0 Kudos

Hi,

I have a requirement to concatenate Text in one Column.

Col A (Key)              Col B              Col C (Text )

101                      203                       ABC

102                      203                       DEF

103                      203                       GHI

I want one row with Text in it.

101       203      ABCDEFGHI

102

103

How would I achieve this in SQL Script Procedure? Sample code ideas would be very helpful.

thanks!

@ak

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Use a generated always statement.

GENERATED ALWAY AS concat(A,B)

Former Member
0 Kudos

Thanks John! But my rek is to Concatenate Data in Col C which has Text in different rows with same PK field..my case system generated unique ID.

@ak

Former Member
0 Kudos

OK, I understand what you are asking for now.

1) Loop through column C with a cursor, and concatenate this into a local scalar text variable

2) Issue an update statement on column C against the key of column A


If you need some more help, could you paste the DDL you are using and the code that you wrote so far.

John

Former Member
0 Kudos

Thanks John! I have a Table with these columns which gets replicated from ECC. I tried doing this in BO but its performance issues on the report side. What would be my best solution Create a Script based view just with One table and populate a Separate Col with concatenated Text in it? Or Procedure would work for me in this case? I need a Sample Code for this ...so far appreciate your response on this. @ak

Former Member
0 Kudos

You are drip feeding me information... so you have a scenario with ERP replicated to HANA via SLT.

You want a view exposed to SAP BO which has the first row of the table.

In addition you want one column appended to that view with the concatenation of all the values in one column.

Is that correct? If so can you paste your DDL? Thanks!

John