SQL Server: Must numbers all be specified with latin numeral digits?

假如想象 提交于 2019-12-07 11:23:56

问题


Does SQL server expect numbers to be specified with digits from the latin alphabet, e.g.:

0123456789

Is it valid to give SQL Server digits in other alphabets?

Rosetta Stone:

Latin:   01234567890
Arabic:  ٠١٢٣٤٥٦٧٨٩
Bengali: ০১২৩৪৫৬৭৮৯

i know that the client (ADO) will convert 8-bit strings to 16-bit unicode strings using the current culture. But the client is also converting numbers to strings using their current culture, e.g.:

SELECT * FROM Inventory
WHERE Quantity > ২৩৪,৭৮

Which throws SQL Server for fits.

i know that the server/database has it's defined code page and locale, but that is for strings.

Will SQL Server interpret numbers using the active (or per-login specified) locale, or must all numeric values be specifid with latin numeral digits?


回答1:


From what I can tell, T-SQL requires latin digits, and decimal points specified as ..

Neither ISNUMERIC() nor CAST() can successfully test these digits, so a numeric constant using those characters would not work either.

Allowing a client to pass non-Latin digits sounds dangerously promiscuous (I'm not sure what path your data travels, but there seems to be a potential for SQL injection if user's localized input isn't being tested to be numeric.



来源:https://stackoverflow.com/questions/2501487/sql-server-must-numbers-all-be-specified-with-latin-numeral-digits

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