I have a table column containing set of addresses as XML data:
<?xml version="1.0" encoding="utf-16"?>
<AddressBook>
<Address>
<ID>-1</ID>
<AddressID>PRIMARY</AddressID>
<FirstName>JOHN L.</FirstName>
<LastName>JOHSON/JOHN L.</LastName>
<StreetLine1>123 NOWHERE ST</StreetLine1>
<City>OVERHERE</City>
<StateName>CA</StateName>
<StateCode>5</StateCode>
<PostalCode>12345</PostalCode>
<CountryName>United States</CountryName>
<CountryCode>en-US</CountryCode>
<PhoneNumber>5551231234</PhoneNumber>
<PhoneNumber2>5551231234</PhoneNumber2>
<TaxScheduleID>CA</TaxScheduleID>
<ShowAddress>1</ShowAddress>
</Address>
<Address>
<ID>-1</ID>
<AddressID>SECONDARY</AddressID>
<FirstName>SAM</FirstName>
<LastName>LARSON/SAM</LastName>
<StreetLine1>456 OVERHERE</StreetLine1>
<City>NOTTHERE</City>
<StateName>CA</StateName>
<StateCode>5</StateCode>
<PostalCode>54321</PostalCode>
<CountryName>United States</CountryName>
<CountryCode>en-US</CountryCode>
<PhoneNumber>5553334444</PhoneNumber>
<PhoneNumber2>5553334444</PhoneNumber2>
<TaxScheduleID>CA</TaxScheduleID>
<ShowAddress>1</ShowAddress>
</Address>
</AddressBook>
My issues is that the last name element contains an unnecessary duplicate of the first named preceding with ‘/’ :
<FirstName>JOHN L.</FirstName>
<LastName>JOHSON/JOHN L.</LastName>
How can I remove the ‘/’ and every character following ‘/’ in the last name elements only to create an outcome as such?
<FirstName>JOHN L.</FirstName>
<LastName>JOHSON</LastName>
Try using
charindex: