如何在sqlserver表中插入希腊字符 [英] How to insert greek characters into sqlserver table
问题描述
我有一个简单的插入,但带有希腊字符
I have a simple insert, but with greek characters
INSERT INTO tmp (fname) VALUES ('ΚΩΝΣΤΑΝΤΙΝΟΣ')
我尝试通过两种方式创建表格:
I have tried creating the table in two ways:
create table tmp (fname varchar(40))
和
create table tmp (fname nvarchar(40))
当我选择数据时:
select * from tmp
我明白了:
?O?S???????S
我正在使用:
Microsoft SQL Server 2005 - 9.00.4060.00 (Intel X86)
Mar 17 2011 13:20:38
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
和
Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64)
Oct 19 2012 13:38:57
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
两者都一样.
我正在使用:
Microsoft SQL Server Management Studio 11.0.2100.60
创建表格并插入数据等
如何让希腊字符正确存储,或者它们是否正确存储以在我选择它们时正确显示?
How do I get Greek characters to store correctly or if they are stored correctly to display correctly when I select them?
推荐答案
尝试使用前缀 Unicode 字符串:
Try to use prefix Unicode character string:
create table tmp (fname nvarchar(40))
INSERT INTO tmp (fname) VALUES (N'ΚΩΝΣΤΑΝΤΙΝΟΣ')
也可能是列的排序有问题,请设置
Also there may be a problem with collation of the columns, please set
create table tmp (fname nvarchar(40) COLLATE SQL_Latin1_General_CP1253_CI_AI)
来自 MSDN:
用字母 N 前缀 Unicode 字符串常量.没有N 前缀,字符串被转换为默认代码页数据库.此默认代码页可能无法识别某些字符.
Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.
这篇关于如何在sqlserver表中插入希腊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!