ssms查询结果毫不零,对于浮点列而没有零

发布于 2025-02-04 09:23:56 字数 160 浏览 2 评论 0原文

我将使用SQLCMD的SSMS查询结果导出到.csv文件,使用Shell脚本。但是,如果表中的任何列是浮动的,则将其结果为123.0而不是123。当我在SSM中执行相同的选择查询时,它是123。如何获得在SSMS结果中显示的相同值。而且我不能将cast/Convert用于该特定列,因为我要为多个表导出结果

I am exporting SSMS query result with SQLCMD to .csv file using shell script. But if any of the column in a table is float, it is resulting as 123.0 instead of 123. When I execute the same select query in SSMS, it is 123. How can I get the same value which is showing in SSMS result. And I can't use cast/convert for that particular columns since I am going to export result for multiple tables

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

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

发布评论

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

评论(1

未蓝澄海的烟 2025-02-11 09:23:56

这是因为SSM本身用于显示目的,而sqlcmd不是。

请让我们查看一些代码,尤其是因为您说您不能使用转换。

您可以将查询中的值转换,也可以保留原始内容,类似的内容:

declare @a float
SELECT @a = 3.33;

SELECT CONVERT(INT, @a), @a

此外,这可能与您有关:在这里

That's because SSMS itself rounds floating point values for display purposes while sqlcmd is not.

Please let us see some code, especially because you're saying that you cannot use convert.

you could convert the value in your query, and also keep the original, something like this:

declare @a float
SELECT @a = 3.33;

SELECT CONVERT(INT, @a), @a

Besides that, this might be relevant for you: here

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