本文介紹了SQL用逗號替換點的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有以下代碼:
SELECT cast(Listenpreis*1.19 as decimal(29,2)) as Listenpreis
FROM [SL_M03KNE].[dbo].[ARKALK]
我得到這個值:5.59
I get this value: 5.59
我嘗試將點替換為 komma,所以我得到了值:5,59
I try to replace the dot to a komma so i get the Value: 5,59
我試試代碼:
SELECT replace((cast(Listenpreis*1.19 as decimal(29,2)) as Listenpreis),'.','))
FROM [SL_M03KNE].[dbo].[ARKALK]
但是語法有問題.有什么想法嗎?
But something is wrong with the Syntax. Any Ideas?
我發(fā)現(xiàn):如果我做一個
select Artikelnummer,Listenpreis*1.19 as money from [SL_M03KNE].[dbo].[ARKALK]
我得到:5,59
如果我這樣做
EXEC master..xp_cmdshell 'bcp "select Artikelnummer,Listenpreis*1.19 as money from [SL_M03KNE].[dbo].[ARKALK]" queryout "D:\shop\xml\Artikelpreise_ohne.csv" -E -c -T -x
bcp 將 komma 轉換為點.我該如何解決這個問題?
the bcp do a conversion from the komma to dot. How can i fixed this?
推薦答案
您的 as Listenpreis
別名位置錯誤.它必須是最后一件事.還有 '.','
部分.
Your as Listenpreis
aliasing is in the wrong place. It needs to be the last thing. Also the '.','
part.
SELECT REPLACE(CAST(Listenpreis*1.19 AS DECIMAL(29,2)) ,'.',',') AS Listenpreis
FROM [SL_M03KNE].[dbo].[ARKALK]
SQLFiddle 演示
這篇關于SQL用逗號替換點的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!