Sql server 2008 将列转换为行-SQLServerStudio管理2008

Sql server 2008 将列转换为行-SQLServerStudio管理2008,sql-server-2008,ms-access-2010,Sql Server 2008,Ms Access 2010,我有3个ID列,它们的THD值不同。我正在尝试将它们转换为行。我尝试过一种不成功的方法 ID1 ID2 ID3 12345 54321 53 9954 8854 6565 7844 54 8744 我希望我的数据显示在一列中 IDS 12345 54321 53 9954 8854 ECT.. Sample code below SELECT * IDS 从独特

我有3个ID列,它们的THD值不同。我正在尝试将它们转换为行。我尝试过一种不成功的方法

 ID1     ID2     ID3
 12345   54321     53
 9954     8854     6565
 7844     54     
 8744
我希望我的数据显示在一列中

 IDS
 12345   
 54321     
 53
 9954     
 8854 
 ECT..     

 Sample code below

 SELECT * IDS
从独特到独特

unpivot [id1]、[id2]、[id3]的出租车 as P

任何帮助都将不胜感激……:
我做的研究越多,我就越觉得unpivot不是最好的途径

选择所有非空值:

select id1 as ids from your_table_name_here where id1 is not null union all
select id2        from your_table_name_here where id2 is not null union all
select id3        from your_table_name_here where id3 is not null
如果您只对不同的值感兴趣,请尝试以下方法:

select id1 as ids from your_table_name_here union
select id2        from your_table_name_here union
select id3        from your_table_name_here