-
Viorel 82,476 Reputation points
2020-08-28T17:50:22.387+00:00 Check an example that is based on JSON, or give missing information:
select JSON_VALUE(j, '$[0].s') as t1, JSON_VALUE(j, '$[1].s') as t2, JSON_VALUE(j, '$[2].s') as t3, JSON_VALUE(j, '$[3].s') as t4, JSON_VALUE(j, '$[4].s') as t5, JSON_VALUE(j, '$[5].s') as t6 from @mytable cross apply ( select s from (values (s1, 1), (s2, 2), (s3, 3), (s4, 4), (s5, 5), (s6, 6)) t(s, n) where s is not null order by n for json auto ) t(j)
(See next comment with sample data).
thx all,
from viorel-qna's data, my t1 would be address line 1, my t2 would be address line 2, my t3 would be address line 3, i dont care if my t4-t6 are nulls or blanks.
i'll try viorel-qna's approach and post back here. i'm not sure how i would explain that solution.