处理在 SQL 查询中未正确显示的 unicode 字符 [英] Handling unicode characters that aren't displayed correctly in SQL query

查看:36
本文介绍了处理在 SQL 查询中未正确显示的 unicode 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 SQL 查询:

DECLARE @objname nvarchar(255)
set @objname='漢字'
select @objname

当我在 Microsoft SQL Server Management Studio 中运行此查询时,我得到以下信息:

When I run this query in Microsoft SQL Server Management Studio, I get the following:

??

问题:是否应该在 SQL 查询中更改任何内容以在结果中获取汉字,或者是代码页等问题?

The question:is there anything I should change in my SQL query to get 漢字 in the result, or it is a matter of codepages, etc?

推荐答案

NVarchar 变量用 N' 表示,所以它是

NVarchar variable are denoted by N'<Value> so it would be

DECLARE @objname nvarchar(255)
set @objname=N'漢字'
select @objname

现在输出将是汉字,因为它已经设置好了.运行上面的代码.

Now the output will be 漢字 as it has been set. Run above code.

这篇关于处理在 SQL 查询中未正确显示的 unicode 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆