my goal is if I have this:
colmuns c1 | c2 | c3 | c4 | c5 | n..
row1 a | a | a | a | a |
row2 b | b | b | b | b |
rowN...
I want to do a query that would return
myCol
aaaaa
bbbbb
nnnnn...
I know I can do this
select t2.id, (
select *
from mytable t1
where t1.id= t2.id
for xml path('')) as row
from mytable t2
and it will put the whole row with many columns into one column like I want
now, how to filter out the xml tag?
or is there any other solution?
edit
column might be null are not varchar, could be int, varchar, date, etc
try:
EDIT working sample:
OUTPUT:
EDIT loop free way to parse table column names from meta data tables, with the ability to format each datatype as desired and supports NULLs:
OUTPUT: