插入阿拉伯字符时 SQL 查询对齐方式发生变化

发布于 2024-08-21 07:54:43 字数 785 浏览 5 评论 0原文

我有这样的查询

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`)

当我用 xxxxxx 替换 xxxxxx 时,字符串后面的查询像这样从右到左

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)

请告诉我如何克服这个问题。

我正在使用 SQL Server 2000 MSDE。

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`)

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

做个少女永远怀春 2024-08-28 07:54:43

您可以通过在输入的每个值(需要转换)之前添加字母 N 来解决这种情况,

例如:

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');

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');
小清晰的声音 2024-08-28 07:54:43

当我们在 nvarchar 值之前添加 N 时,这个问题就得到了解决。

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)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文