开发者

SQL query alignment change when Arabic characters are inserted

开发者 https://www.devze.com 2022-12-19 19:41 出处:网络
I have a query like this SET QUOTED_IDENTIFIER OFF SET DATEFORMAT \'mdy\' INSERT INTO TABLE1 (AccountID, TimeStamp, UserID, NodeID, Deleted, UserPriority,ParentRecordID, NodeLevel, Name, NodeClas

I have a query like this

SET QUOTED_IDENTIFIER OFF 
SET DATEFORMAT 'mdy' 

INSERT INTO TABLE1 
  (AccountID, TimeStamp, UserID, NodeID, Deleted, UserPriority,  ParentRecordID, NodeLevel, Name, NodeClass, DeviceID, DeviceType, SubTypeLevel)  
VALUES 
  (0, "10/03/2002 02:33:39", 0, 0, 0, 0, 0, 0,"XXXXXX",7000, 0, 0, 0`)
开发者_JAVA技巧

When I replace XXXXXX with منطقة تحكم بالبداية السريعة, the query after the string turns right to left like this

SET QUOTED_IDENTIFIER OFF 
SET DATEFORMAT 'mdy' 

INSERT INTO TABLE1 
  (AccountID, TimeStamp, UserID, NodeID, Deleted, UserPriority,  ParentRecordID, NodeLevel, Name, NodeClass, DeviceID, DeviceType, SubTypeLevel)  
VALUES 
  (0, "10/03/2002 02:33:39", 0, 0, 0, 0, 0, 0, "منطقة تحكم بالبداية السريعة", 7000, 0, 0, 0)

Please tell me how to overcome this.

I am using SQL server 2000 MSDE.


You can resolve this case by adding the letter N before each values entered (that need conversion)

For example:

INSERT INTO TABLE1(AccountID, TimeStamp, UserID, NodeID, Deleted, UserPriority, 
       ParentRecordID, NodeLevel, Name, NodeClass, DeviceID, DeviceType, SubTypeLevel)  
VALUES 
  (0, "10/03/2002 02:33:39", 0, 0, 0, 0, 0, 0, "منطقة تحكم بالبداية السريعة"N, 7000, 0, 0, 0) 

=>

Insert ... Into ... Values (id1,id2,..., N'Arabic word',N'Hebrew word',N'Chinese word');


This issue is solved when we add N before the nvarchar value.

SET QUOTED_IDENTIFIER OFF SET DATEFORMAT 'mdy' INSERT INTO ControlTreeEx (AccountID, TimeStamp, UserID, NodeID, Deleted, UserPriority,  ParentRecordID, NodeLevel, Name, NodeClass, DeviceID, DeviceType, SubTypeLevel)  VALUES (0, "10/03/2002 02:33:39", 0, 0, 0, 0, 0, 0, N'منطقة تحكم بالبداية', 7000, 0, 0, 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消