Displaying one record (row) as one column
Yes, there is a TSQL, PIVOT team. And there are several existing topics on this topic; but I cannot find one of them.
My usual answer (probably 5 or 6 of these threads) is to think about using Excel or Access if needed - this is a fairly simple way to convey value to end users. But YMMV.
source to share
You can use unsivot here
Declare @tbl Table
(
c1 int,
c2 int,
c3 int
)
Insert into @tbl Values(1,2,3)
Select
cname,
cval
From
(
Select C1,C2,C3 From @tbl
) t
UNPIVOT
(Cval For Cname In
(C1,C2,C3)
)As U
But it is usually inflexible and slow. You can use union, but it is usually worse in terms of support, but can be fast (need to check) or use dynamic query and union
source to share
If you are looking for something specific i.e. not a general solution, but one that fits your specific DB, then you can do something like this:
select Field1+';'+convert(nvarchar(255), Field2 )+';'+convert(nvarchar(255),Field3 ) from Table
Use conversions for nvarchar (255) so that you don't have problems no matter what characters are in it, remember to correct the sort before starting the selection (you never know what will happen to your orderby and groupby otherwise).
source to share