gpt4 book ai didi

sql-server - 如何在sql server表中插入希腊字符

转载 作者:行者123 更新时间:2023-12-02 09:22:46 26 4
gpt4 key购买 nike

我有一个简单的插入,但带有希腊字符

INSERT INTO tmp (fname) VALUES ('ΚΩΝΣΤΑΝΤΙΝΟΣ')

我尝试通过两种方式创建表格:

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

创建表并插入数据等

如何正确存储希腊字符,或者是否正确存储它们以便在选择它们时正确显示?

最佳答案

尝试使用前缀Unicode字符串:

create table tmp (fname nvarchar(40))
INSERT INTO tmp (fname) VALUES (N'ΚΩΝΣΤΑΝΤΙΝΟΣ')

另外列的排序规则可能有问题,请设置

create table tmp (fname nvarchar(40) COLLATE SQL_Latin1_General_CP1253_CI_AI)

来自MSDN :

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.

关于sql-server - 如何在sql server表中插入希腊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32696216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com