简体   繁体   English

SSIS - 修复源数据中数据类型不正确的数据

[英]SSIS - Fixing data with an incorrect datatype in the source data

I'm an SSIS newbie and I've hit a snag trying to convert what should be a "Duration" column into seconds in my package.我是 SSIS 新手,我在尝试将应该是“持续时间”列的内容转换为我的包中的秒时遇到了障碍。

Essentially the Excel source data column has been incorrectly typed as a TIME datatype in excel with the h:mm AM/PM format (ie. An 11 minute episode is being displayed as 11:00 AM)本质上,Excel 源数据列在 excel 中被错误地输入为 TIME 数据类型,格式为 h:mm AM/PM(即 11 分钟的剧集显示为上午 11:00)

Ideally I would like to convert this to seconds in an int datatype in my DB.理想情况下,我想将其转换为我数据库中 int 数据类型的秒数。 What would be the best way to go about this?解决这个问题的最佳方法是什么?

  1. Create the DFT something like this:像这样创建 DFT:

图像1

  1. Use the following inside derived column : SUBSTRING(REPLACE((DT_STR,100,1252)Duration,":",""),1,4)在派生列中使用以下内容: SUBSTRING(REPLACE((DT_STR,100,1252)Duration,":",""),1,4)

    Duration is my column name in excel, which is DT_Time type(set via advanced editor) Duration是我在excel中的列名,是DT_Time类型(通过高级编辑器设置)

What I am essentially doing is, converting Time to String, removing : , taking the first four character (hhmm).我本质上做的是,将时间转换为字符串,删除: ,取前四个字符(hhmm)。

Hence output is like :因此输出是这样的:

input      output

12:00:00AM  1200
12:30:00AM  1230

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

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