在sqlserver中转换数字格式 [英] converting number format in sqlserver

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

问题描述


我正在将gridview导出到包含十进制数字列的Excel,例如:169939.38.
我的客户(丹麦服务器)想在excel中自动汇总该列,但他做不到.可能是由于丹麦服务器的数字格式为xxx.xxx,xx

因此,如何使我的客户端能够对列求和,我的意思是如何在SQL Server SELECT查询中将数字格式转换为丹麦语.请帮助我

Hi
i am exporting gridview to Excel which contains a decimal number column eg:169939.38.
my client (Danish server) wants to Autosum that column in excel, but he can not do. May the reason be The number format of danish server is xxx.xxx,xx

So how can I enable my client to sum the Column, I mean How can i convert the number format to Danish in SQL server SELECT query..PLease help me

推荐答案

如果一直都是数字,那将不是问题-SQL将其存储为数字,而没有任何'',''或''''字符-浮点数存储为尾数和指数,格式化是在将数据呈现给用户时完成的. SQL不知道您的客户端PC设置了哪种格式编号!

因此,要么将其存储为字符串(错误),要么将其转换为字符串以将其输出到excel(也很糟糕).

检查:
1)是数字字段还是SQL中的字符串?
2)如果是数字,请检查您用于将其导出到excel的代码-可能需要在此处进行修复.
If it is a number all the time, then it wouldn''t be a problem - SQL stores it as a number, without any '','' or ''.'' characters - floats are stored as a mantissa and an exponent, formatting is done when the data is presented to the user. SQL does not know what format numbers your client PC is set for!

So either you are storing it as a string (bad) or converting it to a string to output it to excel (also bad).

Check:
1) Is it a numeric field, or a string in the SQL?
2) If it''s numeric, check the code youi are using to export it to excel - it probably needs to be fixed there.


这篇关于在sqlserver中转换数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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