2012-08-17 89 views
0

我創建使用的數據集在SSIS報告,並具有以下SQL要求:select語句返回附加行

的SQL,則返回三行:

a 
b 
c 

反正我可以有SQL返回一個additioanal行而不向表中添加數據?

由於提前, 布魯斯

回答

2
select MyCol from MyTable 
union all 
select 'something' as MyCol 
0

可以使用UNION ALL包括一個新行。

SELECT * 
FROM yourTable 
UNION ALL 
SELECT 'newRow' 

頂部查詢和底部查詢之間的列數需要相同。所以如果你第一次查詢有一列,那麼第二列也需要一列。

0

如果需要添加多個值有可用的陌生人語法:

declare @Footy as VarChar(16) = 'soccer' 
select 'a' as Thing, 42 as Thingosity -- Your original SELECT goes here. 
    union all 
    select * 
    from (values ('b', 2), ('c', 3), (@Footy, Len(@Footy))) as Placeholder (Thing, Thingosity)