私は、列の1つがXMLコードを1行に集約したテーブルを持っています。 XMLであるため、charIndexを実行することはできません。行内には多くの '<' '>があります。キーワード検索の左側の列に大きな文字列からSQLを抽出する文字列
私は列の文字列検索から2文字のコードを抽出する方法が必要です。
EX)欄が 'XMLMessage' と呼ばれ、含まれています
<p1:UniversalInterchange xmlns:p1="http://www.cargowise.com/Schemas/Native">
<Header xmlns="">
<SenderID/>
<RecipientID/>
</Header>
<Body xmlns="">
<UniversalEvent>
<Event>
<EventType>DEP</EventType>
<EventTime>2016-02-04T13:37:00</EventTime>
<ContextCollection>
<Context>
<Type>MAWBNumber</Type>
<Value>057-23154670</Value>
</Context>
<Context>
<Type>MAWBOriginIATAAirportCode</Type>
<Value>IAD</Value>
</Context>
<Context>
<Type>MAWBDestinationIATAAirportCode</Type>
<Value>TUN</Value>
</Context>
<Context>
<Type>MAWBNumberOfPieces</Type>
<Value>1</Value>
</Context>
<Context>
<Type>OtherServiceInfo</Type>
<Value>
PRD-XPS
</Value>
</Context>
<Context>
<Type>SourceEventCode</Type>
<Value>DEP</Value>
</Context>
<Context>
<Type>NumberOfPieces</Type>
<Value>1</Value>
</Context>
<Context>
<Type>WeightOfGoods</Type>
<Value>2KG</Value>
</Context>
<Context>
<Type>IATACarrierCode</Type>
<Value>AF</Value>
</Context>
<Context>
<Type>FlightNumber</Type>
<Value>1184</Value>
</Context>
<Context>
<Type>FlightDate</Type>
<Value>04-FEB-2016</Value>
</Context>
<Context>
<Type>OriginIATAAirportCode</Type>
<Value>CDG</Value>
</Context>
<Context>
<Type>DestinationIATAAirportCode</Type>
<Value>TUN</Value>
</Context>
<Context>
<Type>TimeOfDeparture</Type>
<Value>2016-02-04T13:37:00</Value>
</Context>
<Context>
<Type>TimeOfArrival</Type>
<Value>2016-02-04T15:40:00</Value>
</Context>
</ContextCollection>
<AdditionalFieldsToUpdateCollection>
<AdditionalFieldsToUpdate>
<Type>JobConsolTransport.JW_ATD</Type>
<Value>2016-02-04T13:37:00</Value>
</AdditionalFieldsToUpdate>
</AdditionalFieldsToUpdateCollection>
</Event>
</UniversalEvent>
</Body>
</p1:UniversalInterchange>
私は 'IATACarrierCode' 検索後に 'AF' を見つける必要があります。
'IATACarrierCode'の後に 'AF'を見つけるためにselect文が必要です。それは常に2文字の後に続きます。私はあなたの質問を理解していれば
使用するXQuery httpsで動作します://それはXML列であると仮定すると、
msdn.microsoft.com/en-us/library/ms191474.aspx –