Query:
SELECT ID, T.c.value('@Address', 'nvarchar(20)' ) as Address
INTO #TMP
FROM TABLE1
CROSS APPLY XMLData.nodes('/Document') AS T(c)
UPDATE TABLE1
SET HomeAddress = (SELECT TOP 1 t.Address
FROM #TMP t
WHERE t.ID = ID)
Mainly, I need to copy data OUT from an XML field to normal fields within the same table.
Questions:
- Any reason why all the records get the HomeAddress on Table1?
- Is really Cursor the only way to update the value on Table1?