Using XQuery in SQL 2005 to replace a node's value?
Given the following XML variable, how can I replace "**UNKNOWN**" in the *StateCode* node with "**FOO**" in TSQL for MS SQL 2005?

    declare @xmldata xml
    
    set @xmldata = 
    
    	'<Collection>
    		<Plan>
    			<StateCode>UNKNOWN</StateCode>
    			<Type>Tubular</Type> 
    		</Plan>
    	</Collection>'


Unlike a [similar question][1] that I found, this is simply an XML typed variable, not a table record.  

Should I simply insert the variable value into a table and go with the method presented in that question, or can I just manipulate the XML variable directly and perform the replacement?


  [1]: http://stackoverflow.com/questions/276009/using-xquery-modify-to-replace-a-piece-of-my-xml-with-value-from-varchar-field
Using XQuery in SQL 2005 to replace a node's value?
===

Given the following XML variable, how can I replace "**UNKNOWN**" in the *StateCode* node with "**FOO**" in TSQL for MS SQL 2005?

    declare @xmldata xml
    
    set @xmldata = 
    
    	'<Collection>
    		<Plan>
    			<StateCode>UNKNOWN</StateCode>
    			<Type>Tubular</Type> 
    		</Plan>
    	</Collection>'


Unlike a [similar question][1] that I found, this is simply an XML typed variable, not a table record.  

Should I simply insert the variable value into a table and go with the method presented in that question, or can I just manipulate the XML variable directly and perform the replacement?


  [1]: http://stackoverflow.com/questions/276009/using-xquery-modify-to-replace-a-piece-of-my-xml-with-value-from-varchar-field