是要在一个表中的,表结构如下:
ID A1 B1 A2 B2
1 a1 b1 a2 b2
2 a10 b10 a20 b20
转换成
ID A1 B1
1 a1 b1
2 a10 b10
3 a2 b2
4 a20 b20
可以这样转换吗?
------解决方案--------------------------------------------------------
- SQL code
select A1,B1 from tbnameunion allselect A2,B2 from tbname
------解决方案--------------------------------------------------------
- SQL code
--Codeselect row_number() over(order by A1) as id,t.* from(select A1,B1 from @Tunion allselect A2,B2 from @T) t--Drop--Result/*id A1 B1-------------------- ---- ----1 a1 b12 a10 b103 a2 b24 a20 b20*/