Jacob,
May be I failed to explain my requirement,
Actually I want to have xml as template and when required I will get that xml with updated values from table.
I solved this problem using following
DECLARE @tblXML TABLE (ID INT, X XML)
INSERT INTO @tblXML (ID, X)
SELECT 1, '<table id="ACCT_NUM">
<label>Acct #:</label>
<value>val</value>
</table>
<table id="PROD">
<label>Product:</label>
<value>val</value>
</table>'
--ACCT_NUM
UPDATE tblXML
SET X.modify('replace value of (//table[@id="ACCT_NUM"]/value/text())[1] with sql:column("ACCT_NUM")')
FROM @tblXML tblXML
INNER JOIN EmployeeAccount eld ON eld.ID = tblXML.ID
--PROD
UPDATE tblXML
SET X.modify('replace value of (//table[@id="PROD"]/value/text())[1] with sql:column("PROD")')
FROM @tblXML tblXML
INNER JOIN EmployeeAccount ea ON ea.ID = tblXML.ID
SELECT X FROM @tblXML
I did little bit change in xml, introduced the id attribute to accessed the node from that specific attributed and then replaced the value from EmployeeAccount table.
now my problem is that if I want to replace multiple values from their respective column than I need to write multiple update queries (as I did in above example),
Can I write above two update queries in single query?
commented on Apr 5 2012 3:02AM