简体   繁体   English

在U SQL中合并2个不相等的列大小行集

[英]merging 2 unequal column size rowsets in u sql

I have a rowsetA with 3 columns. 我有3列的rowetA。 I need to add this rowsetA to an existing rowsetB which has the above 3 columns as well as other columns. 我需要将此rowsetA添加到具有上述3列以及其他列的现有rowsetB中。 How can I add/union above 2 rowsets such that rowsetA will have null/empty/default values for other columns present in rowsetB? 如何在2个行集上方添加/联合,以使rowetA在rowetB中存在的其他列具有null / empty / default值?

The easiest way is to add default null values in rowsetA when doing UNION with rowsetB. 最简单的方法是在对rowsetB进行UNION时在rowsetA中添加默认的空值。

@rowsetA = EXTRACT A string,
B string,
C string 
FROM @path 
USING Extractors.Csv();
@rowsetB = EXTRACT A string,
B string,
C string,
D string,
E string
FROM @path1
USING Extractors.Csv();
@union = SELECT A,B,C,null AS D,null AS E FROM @rowsetA
UNION
SELECT A,B,C,D,E FROM @rowsetB;

This way you will have null value on missing columns. 这样,您将在缺少的列上具有空值。 Note for other data types such as DateTime,int,etc, you just put default(int?) instead of null. 请注意,对于其他数据类型,例如DateTime,int等,您只需放置default(int?)而不是null。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM