SQL Server XML 数据类型和 QUOTED_IDENTIFIER
任何人都可以提供对此的见解吗?
我开发了一个使用 XML 数据类型的导入过程。通过 import sProc 将数据插入到表中后,我运行另一个过程以使用导入的表更新另一个表。
如果更新过程是在 SET QUOTED_IDENTIFIER OFF 的情况下创建的,则会引发异常。我想了解为什么会发生这种情况。
代码如下:
DECLARE @xmlRecords XML
SET @xmlRecords = (SELECT importedXML FROM importTable WHERE importId = @lastImportId)
UPDATE o
SET o.ReferralCode = import.refCode
FROM (
SELECT records.record.value('(@orderId)[1]', 'INT') AS orderId,
records.record.value('(@refCode)[1]', 'VARCHAR(15)') AS refCode
FROM @xmlRecords.nodes('/records/record') records(record)
) import
INNER JOIN tblOrder o ON import.OrderId = o.orderId
我假设它与引用的数据类型('VARCHAR(15)')或 xml 查询路径元素('/records/record')有关。
感谢您提供的任何见解。
Can anyone provide insight into this?
I've developed an import process using an XML data type. After the data is inserted in to a table by the import sProc I run another procedures to update another table with the imported table.
The update procedure throws an exception if it is created with SET QUOTED_IDENTIFIER OFF. I'd like to understand why that is happening.
Here's the code:
DECLARE @xmlRecords XML
SET @xmlRecords = (SELECT importedXML FROM importTable WHERE importId = @lastImportId)
UPDATE o
SET o.ReferralCode = import.refCode
FROM (
SELECT records.record.value('(@orderId)[1]', 'INT') AS orderId,
records.record.value('(@refCode)[1]', 'VARCHAR(15)') AS refCode
FROM @xmlRecords.nodes('/records/record') records(record)
) import
INNER JOIN tblOrder o ON import.OrderId = o.orderId
I'm assuming it has to do with the quoted datatypes ('VARCHAR(15)') or the xml query path elements ('/records/record').
Thanks for any insight you can provide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个非常简单的测试用例
给出
这是在此处传递中记录的
但我还没有看到为什么这是 xQuery 的要求的原因。
A very simple test case
Gives
This is documented in passing here
I haven't seen a reason why this is a requirement for xQuery though.