• To start with, the XML you provided won't parse:

    DECLARE @XML XML = '

    <RuleData ReturnVariable="">

    <MateProperties>

    <Property Key="value" DisplayName="name value" />

    <Property Key="value2" DisplayName="name value2" />

    </MateProperties>

    <ReferenceNames>

    <Item Name="0" Value="=CouplerType + "-1"" />

    <Item Name="1" Value="Driveshaft-1" />

    </ReferenceNames>

    <ReferenceFeatures>

    <Item Name="=CouplerType + "-1"" Value="CSYS_BOREB" />

    <Item Name="Driveshaft-1" Value="CSYS_CouplerINSIDE" />

    </ReferenceFeatures>

    </RuleData>'

    SELECT @XML

    Gets this error message:

    Msg 9410, Level 16, State 1, Line 1

    XML parsing: line 8, character 43, whitespace expected

    In order to use the modify method in SQL, the XML must be parseable. Otherwise you'll need to resort to doing the replace as a string operation.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St