0
給定一個表,爲每行取兩列並顯示兩行的最佳方法是什麼?這裏有一個例子:sql - 將列轉移到行
declare @t table (
id int,
v1 nvarchar(max),
v2 nvarchar(max),
v3 nvarchar(max)
)
insert into @t
select 0, 'hello', 'there', 'filler'
union all select 1, 'hello', 'again', 'filler'
有像這樣的表:
0 hello there filler
1 hello again filler
...我想它看起來就像這樣:
0 hello filler
0 there filler
1 hello filler
1 again filler
我試着做一個UNPIVOT,但鑑於我不需要清除所有列,這對我來說並不合適。