Flatten SQL Server Table to a string -
i have table like:
id | value ---------------- 1 | 1 2 | 2 3 | 3
what need create single string these values, in format:
'1: one, 2: two, 3: three'
i know how using cursors, used column in view, it's not performant option. pointers?
with t(id,value) ( select 1, 'one' union select 2, 'two' union select 3, 'three' ) select stuff( (select ', ' + cast(id varchar(11)) + ': ' + value t xml path ('')) , 1, 2, '')
Comments
Post a Comment