久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何將具有本地化數字格式的文本轉換為 MS SQL

How can I convert text with a localized number format into a number in MS SQL Server?(如何將具有本地化數字格式的文本轉換為 MS SQL Server 中的數字?)
本文介紹了如何將具有本地化數字格式的文本轉換為 MS SQL Server 中的數字?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

假設我有一個德國數字格式1,00"的數字,在 en-US 語言環境中等于 1.0.

Let's say I have a number in the german number format "1,00" which is equal to 1.0 in the en-US locale.

是否有內置的方法可以將 T-SQL 中的此文本轉換為相應的數字?似乎 CONVERT 和 CAST 只接受帶有 '.' 的數字.作為小數點分隔符,我認為沒有辦法告訴他們.

Is there a built-in way to convert this text in T-SQL to the corresponding number? It seems like CONVERT and CAST accept only numbers with '.' as the decimal separator and I see no way to tell them otherwise.

我正在考慮簡單地用 '.' 替換 ','但是如果我有一個像1.000,00"這樣的帶有千位分隔符的德語數字,這會變得很難看.

I was thinking about simply replacing ',' with '.' but this gets ugly if I have a german number with thounsands separator like "1.000,00".

在檢索到錯誤"的 SQL 結果后進行轉換不是一種選擇.

Doing the conversion after retrieving the "wrong" SQL result is not an option.

推薦答案

如果您想在 SQL Server 中執行此操作,則必須創建一個將字符串作為參數的 CLR 存儲過程/用戶定義函數并返回您想要的數字類型.您可能還需要使用一個參數來指示您可能希望使用哪些區域名稱(例如 en-US)來指示用于確定解析模式的區域性.

If you want to do this inside SQL Server, then you will have to create a CLR stored procedure/user-defined function which will take the string as a parameter and return the numeric type that you desire. You might also want to take a parameter that indicates what region names (en-US for example) you might want to use to indicate the culture to use for determining the parsing pattern.

然后,在代碼中,您將在 Double/Decimal/Int32 上調用 TryParse 方法并使用適當的 CultureInfo 來指示解析模式.您可以循環瀏覽其中的一堆,或使用其他一些信息來確定正確的模式.

Then, in the code, you would call the TryParse method on Double/Decimal/Int32 and use the appropriate CultureInfo to indicate the parse pattern. You can cycle through a bunch of them, or use some other information to determine the right pattern.

這篇關于如何將具有本地化數字格式的文本轉換為 MS SQL Server 中的數字?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 天天射天天干 | 国产永久免费 | 天天综合网7799精品 | 欧美一极视频 | 五月网婷婷 | 一区二区三区av | 日本成人久久 | 91精品国产乱码久久久 | 欧美一区二区三区视频在线播放 | 国产激情视频在线观看 | 精品久久久一区二区 | 日韩在线观看一区二区三区 | 国产精品一区在线 | 国产午夜精品久久久 | 亚洲二区在线 | 99久久国产免费 | 成人水多啪啪片 | 国产高清免费视频 | 99re视频精品 | 久久精品久久久久久 | 国产电影一区二区在线观看 | 97伦理 | 久久中文视频 | 国产精品久久久久久模特 | 免费h视频| 欧美日韩一区二区三区不卡视频 | 国产色| 成年人在线视频 | 欧美国产一区二区 | 成年视频在线观看 | 午夜精品久久久久久久久久久久 | 黄色片免费看视频 | 成人亚洲精品久久久久软件 | 日韩高清中文字幕 | www.久久.com| 国产精品久久精品 | 亚洲欧美日韩中文在线 | 免费av观看| 日韩欧美高清dvd碟片 | 国产四虎 | 国产网站在线免费观看 |