无法绑定多部分标识符。[4104]

时间:2017-07-10 11:51:25

标签: sql sql-server sql-server-openxml

我通过XML文件更新表但是当我执行sql代码时会抛出此错误: -

enter image description here

这是我的代码

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

1 个答案:

答案 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