1

データベースに 3 つの語句があります。

例: 「JKH 排水ユニット」

3番目の単語の最初の文字を取得する方法を知っている人はいますか?

「Units」という単語の「U」を抽出する必要があります。

NBSTRING(Phrase, PATINDEX('% % %', Phrase) + 1, 1) を使用しようとしましたが、うまくいきませんでした...

4

1 に答える 1

0

私の狂気に方法を示すためだけに、私はそれを段階的に分解しました:

declare @Phrase varchar(100)
set @Phrase = 'JKH Drainage Units'

/* The first space */
select charindex(' ', @Phrase, 1)

/* The second space */
select charindex(' ', @Phrase, charindex(' ', @Phrase, 1) + 1)

/* The first character after the second space */
select substring(@Phrase, charindex(' ', @Phrase, charindex(' ', @Phrase, 1) + 1)+1, 1)
于 2011-01-13T20:56:37.323 に答える