我通过XML文件更新表但是当我执行sql代码时会抛出此错误: -
这是我的代码
IF(@PreppedUpdateModelXml is NULL OR @PreppedUpdateModelXml.exist('*') = 0)
BEGIN
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @PID OUTPUT,@PreppedUpdateModelXml
UPDATE EquipmentModel
SET [Category] = em.[Category]
SELECT * FROM OPENXML (@PID, '/Root/NewDataSet',2)
WITH ([Category] VARCHAR(50), [ModelID] INT) AS em
WHERE EquipmentModel.ModelID = em.ModelID
END
答案 0 :(得分:1)
这不是使用Openxml
结果更新表的正确语法,请尝试这种方式
UPDATE e
SET [Category] = em.[Category]
FROM EquipmentModel e
JOIN OPENXML (@PID, '/Root/NewDataSet', 2)
WITH ([Category] VARCHAR(50),
[ModelID] INT) em
ON e.ModelID = em.ModelID