在 SSIS 中使用小数字段 [英] Working with Decimal fields in SSIS

查看:38
本文介绍了在 SSIS 中使用小数字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是带 SP2 的 SQL Server 2008.

I'm using SQL Server 2008 w/SP2.

我有一个传入的decimal(9,2) 字段通过我的OLE DB 转换 传入我的记录集目标转换.我看到当我单击目标转换的输入和输出属性选项卡时,出于某种原因,它将此特定字段显示为 DT_NUMERIC 类型.就像是把它读成小数以外的东西?我不知道..我不是 SSIS 专家.

I've got an incoming decimal(9,2) field incoming through my OLE DB transformation to my recordset destination transformation. And I see that when I click on the Input and Output properties tab of the destination Transformation, it's showing this particular field as type DT_NUMERIC for some reason. It's like it's reading it as something other than a decimal? I don't know..I'm not an SSIS guru.

所以继续......我的问题从这里开始,我试图将值填充到这个十进制字段的变量中.在 foreach 循环中,我有一个变量来表示这个十进制字段,以便我可以使用它.

So continuing on...the problem I have starts here with me trying to stuff the value into a variable for this decimal field. In a foreach loop, I have a variable to represent this decimal field so I can work with it.

我认为众所周知的第一个问题是SSIS 变量没有十进制类型.从我自己的测试以及我在那里读到的内容,人们正在使用 object 类型作为变量来使 SSIS 对十进制值满意"?这让我很开心.

The first problem that I believe is pretty well known is SSIS variables do not have a decimal type. And from my own testing and what I've read out there, people are using type object for the variable to make SSIS "happy" with decimal values? It makes mine happy.

但是,在我的 foreach 循环中,我有一个 for 循环.在里面,我使用了一个 E*xecute SQL 任务转换*.在其中,我需要创建一个参数映射到我的变量,以便我可以在此处的 T-SQL 调用中使用该十进制字段.所以现在我看到参数的类型十进制并使用它并将其设置为指向我的变量.

But, then in my foreach loop, I have a for loop. And inside that I'm using an E*xecute SQL Task transformation*. In it, I need to create a parameter mapping to my variable so I can work with that decimal field in my T-SQL call in here. So now I see a type decimal for the parameter and use it and set that to point to my variable.

当我运行 SSIS 并且它命中我的 SQL 调用时,我会在输出窗口中看到它.:

   The type is not supported.DBTYPE_DECIMAL 

所以我在这里碰壁了.我想做的就是使用小数点!!!

So I am hitting a wall here. All I wanna do is work with a decimal!!!

推荐答案

我会尝试将值转换为数据流任务中的 double 或 varchar,而不是对象.请注意,您可能必须在执行 sql 任务中使用 cast 或 convert 语句将类型更改回事务 sql 语句中的十进制.

I would try either converting the value to a double or a varchar in your data flow task rather than an object. Note that you may have to use a cast or convert statement in your execute sql task to change the type back to decimal in your transact sql statement.

这篇关于在 SSIS 中使用小数字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆