ssis 派生列_SSIS脚本组件与派生列

本文介绍了如何使用SSIS的派生列和脚本组件将日期从dd/mm/yyyy格式转换为mm/dd/yyyy。讨论了何时使用派生列和脚本组件,以及如何处理错误。通过示例展示了如何使用派生列,以及脚本组件的代码实现。
摘要由CSDN通过智能技术生成

ssis 派生列

介绍 (Introduction)

In this article, we will show how to convert dates from dd/mm/yyyy to mm/dd/yyyy using the Script component and also derived columns in SSIS. We will also explain when to use a derived column (DC) and when to use the Script Component (SC).

在本文中,我们将展示如何使用Script组件以及SSIS中的派生列将日期从dd / mm / yyyy转换为mm / dd / yyyy。 我们还将说明何时使用派生列(DC)和何时使用脚本组件(SC)。

If you have no experience with the script component or a derived column task, this article is for you. We will do a step by step article.

如果您没有脚本组件或派生列任务的经验,那么本文适合您。 我们将一步一步地做文章。

We will also learn how to handle and fire errors using the script component.

我们还将学习如何使用脚本组件处理和引发错误。

要求 (Requirements)

The following requirements needs to be installed.

需要安装以下要求。

入门 (Getting started)

In this example, we will have a file named dates.txt with the following data:

在此示例中,我们将有一个名为dates.txt的文件,其中包含以下数据:

id, salesdate

id,salesdate

1, 13/07/2018

1,13/07/2018

2, 23/06/2019

2,23/06/2019

3, 22/09/2019

3,22/09/2019

This file contains the dates in the format dd/mm/yyyy and we want to convert the date to the format mm/dd/yyyy.

此文件包含格式为dd / mm / yyyy的日期,我们希望将日期转换为格式为mm / dd / yyyy的日期。

Depending on the country, you will find different formats. Here you have a link as a reference related to the format and country:

根据国家/地区,您会找到不同的格式。 在这里,您有一个链接作为与格式和国家/地区相关的参考:

衍生栏 (Derived Column)

We will first use the DC to convert data from the dd/mm/yyyy format to mm/dd/yyyy.

我们将首先使用DC将数据从dd / mm / yyyy格式转换为mm / dd / yyyy。

In SSDT, create a new SSIS Project. In the SSIS project, drag and drop the data flow:

在SSDT中,创建一个新的SSIS项目。 在SSIS项目中,拖放数据流:

Creating a new SSIS Project

Double click the data flow in the design pane and add a Flat file source, flat file destination and the DC task. Join the tasks with an arrow like this:

双击设计窗格中的数据流,然后添加平面文件源,平面文件目标和DC任务。 使用如下箭头连接任务:

SSIS data flow diagram

Double click the Flat File Source and press the new button:

双击平面文件源,然后按新按钮:

SSIS Flat File Source Editor

Specify the path where the dates.txt file is stored. This file contains the date with the dd/mm/yyyy option.

指定dates.txt文件的存储路径。 该文件包含带有dd / mm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值