if its 2005 or above better to use xml functions like nodes() etc over OPENXMLdeclare @x xml='<SchemaType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/process"><AwardYear>AY2013_14</AwardYear><Fields><FieldSchema><Comments>AAI: Adjusted Available Income</Comments><DbLocation>IsirData</DbLocation><FieldCode>AAI</FieldCode><FieldNumber>306</FieldNumber><ReportDisplay>Data</ReportDisplay><ValidContent><ValidValueContent xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><d5p1:KeyValueOfstringstring><d5p1:Key>Blank</d5p1:Key><d5p1:Value>None calculated</d5p1:Value></d5p1:KeyValueOfstringstring></ValidValueContent></ValidContent></FieldSchema></Fields></SchemaType>';WITH XMLNAMESPACES ('http://www.w3.org/2001/XMLSchema-instance' as i,'http://schemas.datacontract.org/process' as [default],'http://schemas.microsoft.com/2003/10/Serialization/Arrays' as d5p1)SELECT t.u.value('../../default:AwardYear[1]','varchar(10)') AS AwardYr,t.u.value('default:Comments[1]','varchar(100)') AS Comments,t.u.value('default:FieldCode[1]','varchar(100)') AS FieldCode,t.u.value('default:FieldNumber[1]','int') AS FieldNumber,t.u.value('(//d5p1:Key)[1]','varchar(100)') AS [Key],t.u.value('(//d5p1:Value)[1]','varchar(100)') AS ValueFROm @X.nodes('/default:SchemaType/default:Fields/default:FieldSchema')t(u)output----------------------------------------------------------------------------------------------------AwardYr Comments FieldCode FieldNumber Key Value-----------------------------------------------------------------------------------------------------AY2013_14 AAI: Adjusted Available Income AAI 306 Blank None calculated
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs