在SQL Server 2005中存储UniCode [英] Storing UniCode in SQL server 2005

查看:85
本文介绍了在SQL Server 2005中存储UniCode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家,如果我们要将UNICODE文本存储在数据库表的字段中,应该使用哪种数据类型,例如devnagri中的人名.

在MS-Access中,我采用了字段类型"文本",它可以工作,但是在SQL Server 2005中却不起作用.

我的操作系统是Windows 7 Ultimate. 64位

在此先感谢.

-prateek.

Hello experts, Which data type we should take if we want to store UNICODE text in a field of a database table, say name of a person in devnagri.

In MS-Access, i have taken the field type ''Text'' and it works, but the same does not work in SQL Server 2005.

My OS is Windows 7 ultimate. 64 bit

thanks in advance.

-prateek.

推荐答案

您需要使用collation
http://msdn.microsoft.com/en-us/library/ms143508 (v = sql.90).aspx [
You need to use collation
http://msdn.microsoft.com/en-us/library/ms143508(v=sql.90).aspx[^]
ALTER COLUMN Column1 NVARCHAR(100)
COLLATE Indic_General_90_CI_AS


将字段数据类型设为 nvarchar(len)


其中 len 是字段长度

插入时在字段的值前加上"N"作为前缀,例如

Take the Field Data Type as nvarchar(len)


where len is the field length

prefix the value of the field with ''N'' while inserting, like

strQuery = "INSERT INTO TableName( Col1, Col2, Col3) VALUES (" +
                   "\'" + Val1 + "\'," +
                   "\'" + Val2 + "\'," +
                   "N\'"+ val3 + "\')";



注意col3值之前的N.如上所示,
在上面的代码段中, Col3 具有Unicode文本.



notice the N before the value of col3. as seen above,
in the above code segment, Col3 has Unicode Text.


这篇关于在SQL Server 2005中存储UniCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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