SSIS 导入到 MS-Access 数据库期间 SQL Server 实数/浮点精度发生变化

发布于 2024-09-09 10:57:00 字数 687 浏览 1 评论 0原文

我正在使用 SSIS 从 SQL Server 数据库中的 2 个视图获取结果,将它们联合(使用适当的映射)、过滤它们并将它们放入 Access 数据库中。

这个过程正在发挥作用,但某些数据的精度正在发生变化。

我已经意识到存储近似值的正常浮点/实数问题(例如 SQL Server 为浮点数提供了额外的精度?),但是 SSIS 引用的视图(“数据传输视图”)正在从其他视图(“部分级别视图”,从 nvarchar 转换为实数/浮点)中进行选择),按以下方式显式转换:

,CONVERT(real,ISNULL(FieldName, 0)) AS Alias

并出现在数据传输视图结果中为 2 dp 访问列被定义为字段大小=双精度、小数位数=2的数字。

然而,访问中显示的是浮点/实数近似值,而不是 2 dp 的数字。

访问字段必须是数字而不是文本,因此我无法重新转换为 nvarchar。

有一个简单的解决方案吗?

更新:将字段大小从双精度更改为单精度可以修复此问题。 为什么Double的字段大小会改变数字的精度,并且为什么不按照Double指定的小数位数显示它?

I am using SSIS to grab the results from 2 Views in a SQL Server database, union them (with appropriate mapping), filter them and place them into an Access database.

This process is working, but the precisions of certain data are changing.

I was already aware of the normal float/real problem of storing approximate values (e.g. SQL Server makes up extra precision for floats?), however the views being referenced by SSIS ("data transfer views") are selecting from other views ("part level views", which convert from nvarchars to real/float) which explicitly convert in the following way:

,CONVERT(real,ISNULL(FieldName, 0)) AS Alias

and appear in the data transfer view results to 2 d.p.
The Access column is defined as a Number with Field size=Double, Decimal places=2).

Yet, the float/real approximated value is being displayed in access, rather than the figure to 2 d.p.

The access fields must be Number and not Text, so I can't recast to nvarchar.

Is there a simple solution to this?

Update: Changing the field size from Double to Single fixes this issue.
Why does the Field size of Double change the precision of the number and why does it not display it according to the specified number of decimal places for a Double?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白芷 2024-09-16 10:57:00

检查 DecimalPlaces 属性的 Access 帮助主题:

“注意,如果 Format 属性为空或设置为常规数字,则 DecimalPlaces 属性设置无效。”

因此,请尝试修改字段的 Format 属性,看看是否可以获得您想要显示的内容。

Check the Access Help topic for DecimalPlaces Property:

"Note The DecimalPlaces property setting has no effect if the Format property is blank or is set to General Number."

So try modifying the field's Format property, to see if you can get what you want displayed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文