SQL UPDATE不适用于外语(阿拉伯语)

时间:2012-06-18 10:48:52

标签: sql sql-server-2008

如果updater字段是用阿拉伯语写的,则UPDATE给出????,这是我的查询:

UPDATE  students 
SET first_name = 'الاسم' , last_name = 'الاسم الاخير' , 
    father_name = 'الاسم الاخير' , mother_name = '', 
    birth_date = '1/1/1990 12:00:00 AM' , education_level = '' , 
    address = '' , notes = '' 
WHERE student_id = 33

以下是更新的结果:

student_id  first_name  last_name   mother_name     father_name   birth_date    
33           ?????      ?????          ??????       ???????????   1990-01-01

//答案很棒,谢谢大家,另一个问题是我在C#程序中使用这种UPDATE语法

command.CommandText = "UPDATE  students SET " +
        "first_name = " + "'" + first_name + "'" + " , last_name = " + "'" + last_name + "'" +
         " , father_name = " + "'" + father_name + "'" + " , mother_name = " + 
        "'" + mother_name + "'" + ", birth_date = " + "'" + birth_date + "'" +
        " , education_level = " + "'" + education_level + "'"  +
        " , address = " + "'" + address + "'" + " , notes = " + "'" + notes + "'" +
        " WHERE student_id = " + id ;

//如何使用字符N

2 个答案:

答案 0 :(得分:7)

您忘记了字符串文字之前的N前缀,因此它们将被视为nvarchar而不是varchar

SET first_name = N'الاسم'等。

没有这个,文本被强制转换为默认排序规则的代码页可以处理的任何字符。

答案 1 :(得分:0)

使用此排序规则Arabic_CI_AS创建数据库,您不需要在阿拉伯字符前添加N.