”“x10D”转换为“c”通过 SQL Server 2008 查询时

发布于 2024-12-10 22:39:29 字数 268 浏览 0 评论 0原文

当选择/插入到我的 SQL Server 2008 数据库中时,正在转换中欧字符。

例如:

Select 'Kutenič'

返回:

Kutenic

这是为什么?我怎样才能防止这种情况发生?我的 ASP.NET Web 应用程序也会遇到类似的问题吗?

When Selecting/Inserting into my SQL Server 2008 database, Central European characters are being converted.

For example:

Select 'Kutenič'

Returns:

Kutenic

Why is this? And how can I prevent this from happening? Would my ASP.NET Web Application have a similar problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不忘初心 2024-12-17 22:39:29

使用 N 前缀

Select N'Kutenič'

如果没有它,字符串将被转换为数据库默认排序规则的代码页。

或者,如果更适合您的区域设置,则将数据库的默认排序规则设置为以下之一。

Albanian_X
Albanian_100_X
Bosnian_Latin_100_X
Croatian_X
Croatian_100_X
Czech_X
Czech_100_X
Estonian_X
Estonian_100_X
Hungarian_X
Hungarian_100_X
Hungarian_Technical_X
Hungarian_Technical_100_X
Latvian_X
Latvian_100_X
Lithuanian_X
Lithuanian_100_X
Polish_X
Polish_100_X
Romanian_X
Romanian_100_X
Serbian_Latin_100_X
Slovak_X
Slovak_100_X
Slovenian_X
Slovenian_100_X
Turkmen_100_X
SQL_Croatian_CP1250_X
SQL_Czech_CP1250_X
SQL_Estonian_CP1257_X
SQL_Hungarian_CP1250_X
SQL_Latin1_General_CP1250_X
SQL_Latin1_General_CP1257_X
SQL_Latvian_CP1257_X
SQL_Lithuanian_CP1257_X
SQL_Polish_CP1250_X
SQL_Romanian_CP1250_X
SQL_Slovak_CP1250_X
SQL_Slovenian_CP1250_X

Use the N prefix

Select N'Kutenič'

Without it the string will be cast to the code page of your database's default collation.

Or set your database's default collation to one of the following if that is more appropriate for your locale.

Albanian_X
Albanian_100_X
Bosnian_Latin_100_X
Croatian_X
Croatian_100_X
Czech_X
Czech_100_X
Estonian_X
Estonian_100_X
Hungarian_X
Hungarian_100_X
Hungarian_Technical_X
Hungarian_Technical_100_X
Latvian_X
Latvian_100_X
Lithuanian_X
Lithuanian_100_X
Polish_X
Polish_100_X
Romanian_X
Romanian_100_X
Serbian_Latin_100_X
Slovak_X
Slovak_100_X
Slovenian_X
Slovenian_100_X
Turkmen_100_X
SQL_Croatian_CP1250_X
SQL_Czech_CP1250_X
SQL_Estonian_CP1257_X
SQL_Hungarian_CP1250_X
SQL_Latin1_General_CP1250_X
SQL_Latin1_General_CP1257_X
SQL_Latvian_CP1257_X
SQL_Lithuanian_CP1257_X
SQL_Polish_CP1250_X
SQL_Romanian_CP1250_X
SQL_Slovak_CP1250_X
SQL_Slovenian_CP1250_X
棒棒糖 2024-12-17 22:39:29

几年前我也有同样的问题需要解决。我只记得我们寻找解决方案所遵循的两条路线是:

  1. 正如#Martin 所提议的,我们检查了排序规则问题,
  2. 但我认为正确的解决方案是更改字段数据类型,其中 char\varchar 字段无法存储来自多个字符集。然后我们遇到了法语和罗马尼亚语字母之间的混淆问题。解决方案是将 char\varchar 字段切换为 nchar\nvarchar (UTF-8 兼容)字段。

I had the same issue to solve a few years ago. I just remember that the two tracks we followed to find the solution were:

  1. As proposed by #Martin, we checked the collation issue
  2. but I think the right solution was to change the field data type, where char\varchar fields could not store characters from more than one character set. We had then confusing problems between french and roumanian alphabet. The solution was then to switch the char\varchar fields into nchar\nvarchar (UTF-8 compatible) fields.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文