SQL Server: Must numbers all be specified with lat

2019-05-07 18:30发布

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条回答
叛逆
2楼-- · 2019-05-07 19:11

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.

查看更多
登录 后发表回答