lower-case 関数 (XQuery)

lower-case 関数は、$arg 内の各文字を小文字に変換します。Unicode コード ポイント用の Microsoft Windows バイナリ大文字/小文字変換では、文字を小文字に変換する方法が指定されています。この標準は、Unicode コード ポイントのマップの標準とは異なります。

構文

fn:lower-case($arg as xs:string?) as xs:string

引数

用語

定義

$arg

小文字に変換する文字列値。

説明

$arg の値が空の場合、長さが 0 の文字列が返されます。

使用例

A. 文字列を小文字に変更する

次の例では、入力文字列 'abcDEF!@4' を小文字に変更します。

DECLARE @x xml = N'abcDEF!@4';
SELECT @x.value('fn:lower-case(/text()[1])', 'nvarchar(10)');

以下に結果セットを示します。

abcdef!@4

B. 特定の文字列を検索する

この例では、lower-case 関数を使用して、大文字と小文字を区別せずに検索を行う方法を示しています。

USE AdventureWorks
GO
--WITH XMLNAMESPACES clause specifies the namespace prefix
--to use. 
WITH XMLNAMESPACES ('https://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelDescription' AS pd)
--The XQuery contains() function is used to determine whether
--any of the text nodes below the <Summary> element contain
--the word 'frame'. The lower-case() function makes the 
--case insensitive.

SELECT ProductModelID, CatalogDescription.query('
      <Prod>
         { /pd:ProductDescription/@ProductModelID }
         { /pd:ProductDescription/pd:Summary }
      </Prod>
 ') as Result
FROM Production.ProductModel
where CatalogDescription.exist('
/pd:ProductDescription/pd:Summary//text()[
          contains(lower-case(.), "FRAME")]')  = 1

以下に結果セットを示します。

ProductModelID の結果

-------------- ---------

19 <Prod ProductModelID="19">

<pd:Summary xmlns:pd="https://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelDescription">

<p1:p xmlns:p1="http://www.w3.org/1999/xhtml">Our top-of-the-line competition mountain bike.

Performance-enhancing options include the innovative HL Frame,

super-smooth front suspension, and traction for all terrain.

</p1:p>

</pd:Summary>

</Prod>

25 <Prod ProductModelID="25">

<pd:Summary xmlns:pd="https://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelDescription">

<p1:p xmlns:p1="http://www.w3.org/1999/xhtml">This bike is ridden by race winners.Developed with the

Adventure Works Cycles professional race team, it has a extremely light

heat-treated aluminum frame, and steering that allows precision control.

</p1:p>

</pd:Summary>

</Prod>