SQLServer 2008:在经典 ASP 中显示带有 Money 数据类型的信息

发布于 2024-09-28 17:21:14 字数 428 浏览 0 评论 0原文

我正在使用 MS SQL 2008 来开发一个带有经典 ASP 的系统。

我想显示字段数据类型是金钱的小数点后 3 位。我从此 http://www.sqlusa.com/bestpractices2005/moneyformat/ 得到答案。

我在我的 SQL 语句中这样使用:

        CONVERT(VARCHAR, CAST(Sell_Price AS Decimal(19, 3))) AS Unit_Price

我想知道的是:是否有比我当前的方法更有效的方法(在性能和使用方面)?如果有的话,请告诉我。提前致谢!

问候,

红魔

I am using MS SQL 2008 to develop one system with Classic ASP.

I want to show 3 Decimal Places the field Datatype is money. I got answer from this http://www.sqlusa.com/bestpractices2005/moneyformat/ .

I use like this in my SQL Statement :

        CONVERT(VARCHAR, CAST(Sell_Price AS Decimal(19, 3))) AS Unit_Price

What I want to know is: Is there more effective way(in performance and usage) than my current one? If there is, please show me. Thanks in advance!

Regards,

RedsDevils

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

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

发布评论

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

评论(1

以可爱出名 2024-10-05 17:21:14

就我个人而言,我会考虑从数据库中返回未格式化的值,并将其格式化以在 UI 中显示 - 将格式化留给前端。毕竟,数据库不知道它返回的数据有什么用途 - 例如,运行查询的其他东西可能需要返回完整的准确性,这样就可以节省多个不同版本的麻烦。

Personally, I'd consider returning the value as-is unformatted from the database and formatting it for display in the UI instead - leave the formatting up to the front end. After all, the db doesn't know for what use the data it returns is being used for - e.g. something else that runs the query may want the full accuracy returned so would save having multiple different versions.

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