Search code examples
c#sqlms-accessoledb

Combine and store multiple SQL columns into a single column programmatically


I have multiple columns in an Access DB, I want to combine the fields A, B, C and store them in column D with a comma separator between them. D = A,B,C.

Right now I am using a OleDbConnection, but I'm open to other methods. How can I combine and store the row data from multiple SQL columns into a single column?


Solution

  • Assuming the simple case of strings, you can use an update statement:

    Update table set D=A+','+B+','+C
    

    This may not be a good idea however. You may want to extrapolate on "Why" you want to do this, as there may be a better option.