十进制的适当.Net数据类型(20,0)

时间:2022-06-01 19:22:44

I've got some sql returning a decimal(20,0) data type. In SSIS I have a package with a foreach loop. In my variable mappings, what type of variable would I map it to? I've tried Int32, Int64, double, and still get the error "The type of the value being assigned to variable "User::iID" differs from the current variable type..."

我有一些sql返回十进制(20,0)数据类型。在SSIS中,我有一个包含foreach循环的包。在我的变量映射中,我将它映射到哪种类型的变量?我已经尝试过Int32,Int64,double,但仍然得到错误“赋值给变量的值的类型”User :: iID“与当前变量类型不同......”

7 个解决方案

#1


2  

The SSIS variable designer did not, in my case, show the Decimal or Numeric data types to select to place my decimal(18,2) value into.

在我的例子中,SSIS变量设计器没有显示要选择的十进制或数字数据类型以将我的小数(18,2)值放入。

I changed my variable to Object, and was able to read the Decimal(18,2) value from the result set of one stored proc, and pass it as a parameter with type Money to a second SP.

我改变变量到对象,并能够读取的十进制(18,2)从结果集合中的一个存储的过程的值,并把它作为与类型金钱的参数为第二SP。

So I would use "Object" if you cannot find a type in the variable list that works for you.

如果你在变量列表中找不到适合你的类型,我会使用“对象”。

#2


2  

Have you tried Decimal yet?

你试过Decimal了吗?

#3


1  

SSIS does have Decimal and Numeric types. You can use either of these and it'll go through (except maybe on a Union All, where you should make sure they're the same precision and scale).

SSIS确实具有十进制和数字类型。您可以使用其中任何一个,它将会通过(除了可能在Union All上,您应该确保它们具有相同的精度和比例)。

See more about data types here.

在此处详细了解数据类型。

#4


0  

.NET decimal has methods decimal.ToInt64(), decimal.ToInt32() etc.

.NET decimal有方法decimal.ToInt64(),decimal.ToInt32()等。

#5


0  

A float or a decimal would be my recommendation.

浮动或小数将是我的建议。

#6


0  

A SQL decimal(20,0) has a precision of 20 which equates to 13 bytes of storage. The .Net decimal is 16 bytes and should work.

SQL十进制(20,0)的精度为20,相当于13个字节的存储空间。 .Net十进制是16个字节,应该可以工作。

#7


0  

You would need to convert the SQL data type to an Int64 prior to putting it into a Int64 package variable.

在将SQL数据类型放入Int64包变量之前,您需要将其转换为Int64。

How are you getting it, as an output parameter?

作为输出参数,你如何得到它?

In a dataflow, you would obviously read it into a decimal/numeric and then convert to Int64 in a Data Conversion component.

在数据流中,您显然会将其读入十进制/数字,然后在数据转换组件中转换为Int64。

If you're trying to directly map an output parameter from an Execute SQL Command task, you'll probably have to use a temporary object package variable and then convert it in a script task into the real Int64 package variable.

如果您尝试直接映射来自Execute SQL Command任务的输出参数,则可能必须使用临时对象包变量,然后将脚本任务中的转换为真实的Int64包变量。

#1


2  

The SSIS variable designer did not, in my case, show the Decimal or Numeric data types to select to place my decimal(18,2) value into.

在我的例子中,SSIS变量设计器没有显示要选择的十进制或数字数据类型以将我的小数(18,2)值放入。

I changed my variable to Object, and was able to read the Decimal(18,2) value from the result set of one stored proc, and pass it as a parameter with type Money to a second SP.

我改变变量到对象,并能够读取的十进制(18,2)从结果集合中的一个存储的过程的值,并把它作为与类型金钱的参数为第二SP。

So I would use "Object" if you cannot find a type in the variable list that works for you.

如果你在变量列表中找不到适合你的类型,我会使用“对象”。

#2


2  

Have you tried Decimal yet?

你试过Decimal了吗?

#3


1  

SSIS does have Decimal and Numeric types. You can use either of these and it'll go through (except maybe on a Union All, where you should make sure they're the same precision and scale).

SSIS确实具有十进制和数字类型。您可以使用其中任何一个,它将会通过(除了可能在Union All上,您应该确保它们具有相同的精度和比例)。

See more about data types here.

在此处详细了解数据类型。

#4


0  

.NET decimal has methods decimal.ToInt64(), decimal.ToInt32() etc.

.NET decimal有方法decimal.ToInt64(),decimal.ToInt32()等。

#5


0  

A float or a decimal would be my recommendation.

浮动或小数将是我的建议。

#6


0  

A SQL decimal(20,0) has a precision of 20 which equates to 13 bytes of storage. The .Net decimal is 16 bytes and should work.

SQL十进制(20,0)的精度为20,相当于13个字节的存储空间。 .Net十进制是16个字节,应该可以工作。

#7


0  

You would need to convert the SQL data type to an Int64 prior to putting it into a Int64 package variable.

在将SQL数据类型放入Int64包变量之前,您需要将其转换为Int64。

How are you getting it, as an output parameter?

作为输出参数,你如何得到它?

In a dataflow, you would obviously read it into a decimal/numeric and then convert to Int64 in a Data Conversion component.

在数据流中,您显然会将其读入十进制/数字,然后在数据转换组件中转换为Int64。

If you're trying to directly map an output parameter from an Execute SQL Command task, you'll probably have to use a temporary object package variable and then convert it in a script task into the real Int64 package variable.

如果您尝试直接映射来自Execute SQL Command任务的输出参数,则可能必须使用临时对象包变量,然后将脚本任务中的转换为真实的Int64包变量。