Like this:DECLARE @idoc intDECLARE @doc varchar(5000)SET @doc ='<forms uniqueid= "336" ><field><name>f_name</name><value>John</value></field><field><name>l_name</name><value>Doe</value></field></forms>'EXEC sp_xml_preparedocument @idoc OUTPUT, @docInsert into NewtableSelect uniqueid,Max(Case when [name] = 'f_name' then [value] else null end)as [First_nm],Max(Case when [name] = 'l_name' then [value] else null end)as [Last_nm]from(Select * fromopenxml(@idoc, '/forms/field',2)with (uniqueid int '../@uniqueid', [name] varchar(20), [value] varchar(20)))xGroup by uniqueidEXEC sp_xml_removedocument @idoc