我正在sqlserver中创建字典表。
我要插入Unicode代码\ u0C2D \ u0C3E \ u0C37。插入sqlserver以显示国际字符时如何编码它们。
我正在使用NCHAR作为该特定列的数据类型。
谢谢K
正如nonnb所说,您可能只需要在INSERT语句中使用Unicode文字语法即可。如果由于某种原因您无法使用Unicode文字语法并且必须对特定的代码点进行编码,请使用NCHAR()函数。以下示例显示了这两个示例:
-- create temp table for this example
create table #TestDictionary (
[Key] nchar(10),
Value nvarchar(100)
)
-- insert dictionary entries for the 3 specific code points mentioned
insert into #TestDictionary ([Key],Value)
values (nchar(0x0C2D), 'TELUGU LETTER BHA')
insert into #TestDictionary ([Key],Value)
values (nchar(0x0C3E), 'TELUGU VOWEL SIGN AA')
insert into #TestDictionary ([Key],Value)
values (nchar(0x0C37), 'TELUGU LETTER SSA')
-- If your keyboard allows you to type it into the script directly then it
-- is probably easiest to just use unicode literal syntax.
insert into #TestDictionary ([Key],Value)
values (N'? ', 'TELUGU LETTER KA')
-- Non-unicode string literals can also be inserted into NCHAR/NVARCHAR columns
insert into #TestDictionary ([Key],Value)
values ('A', 'LATIN CAPITAL LETTER A')
select *
from #TestDictionary
Run Code Online (Sandbox Code Playgroud)
NCHAR()的参考和示例可以在http://msdn.microsoft.com/zh-cn/library/ms182673.aspx中找到
| 归档时间: |
|
| 查看次数: |
6119 次 |
| 最近记录: |