2017-07-10 70 views
1

我更新表通過XML文件,但是當我執行的SQL代碼扔了這個錯誤: -多部分標識符不能被綁定。[4104]

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

那不是正確的語法用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 
相關問題