0

I have the following SQL table

 Column1 | Column2 | Column3 | Column4 | Column5
 1       | Alex    | Summers |   78    | varbinary content of File1.txt
 2       | Steve   | Jones   |   26    | varbinary content of File2.txt
 3       | Steve   | Jones   |   26    | varbinary content of File3.txt
 4       | Steve   | Jones   |   26    | varbinary content of FileX.txt
 5       | Shai    | Agassi  |   33    | varbinary content of File5.txt
 6       | Shai    | Agassi  |   33    | varbinary content of File8.txt
 7       | Nora    | Akeel   |   90    | varbinary content of File11.txt

I would like to create a new table with same columns but rows aggregated such that if columns values of 2nd 3rd and 4th are same, then I would like to combine the varbinary contents of column5. That is

 Column1 | Column2 | Column3 | Column4 | Column5
 1       | Alex    | Summers |   78    | varbinary content of File1.txt
 2       | Steve   | Jones   |   26    | varbinary content of File2.txt File3.txt FileX.txt
 3       | Shai    | Agassi  |   33    | varbinary content of File5.txt File8.txt
 4       | Nora    | Akeel   |   90    | varbinary content of File11.txt

I can combine the contents of varbinary using a C# program but was just wondering if there is any SQL function I could use to know which rows I need to combine.

Ortiga
  • 8,455
  • 5
  • 42
  • 71
blue piranha
  • 3,706
  • 13
  • 57
  • 98
  • Which SQL engine? MSSQL? – Ortiga Sep 04 '14 at 14:54
  • You can create a view and use pure SQL to solve this. See http://stackoverflow.com/questions/18362653/concatenate-many-rows-into-a-single-text-string-with-grouping and http://stackoverflow.com/questions/273238/how-to-use-group-by-to-concatenate-strings-in-sql-server for more. – WeSt Sep 04 '14 at 14:56

0 Answers0