Select a from a
Union all
Select b from A
So no problem, but there are hidden dangers, performance is essentially will scan A table, two logical reads will surge and multiplying, but if you select A, b from A multiple consumption performance will reduce, and in fact have been read to A and b, is there any way to read only once A table to realize the union under the condition of all the vertical stitching way? Or better than union all performance, also there are several dozens of union all are now facing is, data is merged the same associative table of the same type, individual table data volume millions, with the union all performance is slow,
CodePudding user response:
Values can be usedCodePudding user response:
The SELECT tt. Val
The FROM (SELECT 10 AS A, 20 B AS the UNION ALL SELECT 30, 40) t
OUTER APPLY (SELECT * FROM (VALUES (t.A), (t.B)) x (val)) tt;
CodePudding user response:
Transfer line column unpivot know about theSelect * from table
UNPIVOT
(
X FOR y IN (field 1, 2, field 3, field 4)
)p
CodePudding user response:
The