How can I get a number with a thounds separator on top?

落花浮王杯 提交于 2019-12-04 06:52:15

问题


SELECT count(*) FROM table A

let's say the result is 8689. How can I convert it to 8'689 on the SQL Server?


回答1:


Try This way:-

select replace(convert(varchar,convert(Money,  count(*)),1),'.00','') 
from table_name

and be sure you really need this approach, formatting the application is the usual and best as SqlZim said.

UPDATE:-

for setting the separator on top, Try the next:-

select replace( replace(convert(varchar,convert(Money,  count(*)),1),'.00',''),',','''')
from table_name


来源:https://stackoverflow.com/questions/43119241/how-can-i-get-a-number-with-a-thounds-separator-on-top

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!