declare @XML xml =null,@XMLDOC Int
declare @TempTable Table(ItemID int, ItemName nvarchar(50))
EXEC sp_xml_preparedocument @XMLDOC output,
INSERT INTO @TempTable(ItemID, ItemName)
SELECT UOMID from openXML (@XMLDOC,'NewDataSet/Table1',2)
with (ItemID int, ItemName nvarchar(50))
EXEC sp_xml_removedocument @XMLDOC
MERGE ItemMaster as Target
Using(select ItemID,ItemName FROM @TempTable) as Source
ON(Target.Item_ID=Source.ItemID)
WHEN MATCHED THEN
Update set Target.Item_ModifiedOn=GETDATE()
WHEN NOT MATCHED THEN
INSERT(ItemName,Item_CreatedOn)
Values(Source.ItemName,GETDATE());