sql - Return Multiple Rows in One Cell -


so i've looked around , seen xml trick , variable trick, , neither made enough sense me implement. have table 4 columns, first unique identifier, second relation different table, third varbinary(max), last string. want combine columns 3 , 4 on column two. possible?

example of data:

| fileid  |  uniquei1  |  binarydata  | filename | |---------+------------+--------------+----------| |   1     |     1      |    <byte>    | asp.jpg  | |   2     |     1      |    <byte>    | asp1.jpg | |   3     |     2      |    <byte>    | asp2.jpg | |   4     |     2      |    <byte>    | asp3.jpg | |   5     |     2      |    <byte>    | asp4.jpg | 

preferred output:

|  uniquei1  |          binarydata          |          filename            | |------------+------------------------------+------------------------------| |     1      |    <byte>, <byte>            | asp.jpg, asp1.jpg            | |     2      |    <byte>, <byte>, <byte>    | asp2.jpg, asp3.jpg, asp4.jpg |     

i appreciate may able provide me.

sounds you're trying group data , aggregate binarydata , filename columns concatenating values.

there no built-in aggregates concatenation in t-sql, there couple of ways reach same results.

in opinion, far easiest way write custom aggregate in c# leveraging clr. can done using stuff or xml. should have @ does t-sql have aggregate function concatenate strings?


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -