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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -