Freigeben über


upper-case-Funktion (XQuery)

Diese Funktion konvertiert jedes Zeichen in $arg in die entsprechende großgeschriebene Variante. Die binäre Konvertierung der Groß-/Kleinschreibung für Unicode-Codepunkte von Microsoft Windows gibt an, wie Zeichen in Großbuchstaben konvertiert werden. Dieser Standard unterscheidet sich vom Unicode-Standard für die Zuordnung von Codepunkten.

Syntax

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

Argumente

Ausdruck

Definition

$arg

Der Zeichenfolgenwert, der in Großbuchstaben konvertiert werden soll.

Hinweise

Wenn der Wert $arg leer ist, wird eine leere Zeichenfolge zurückgegeben.

Beispiele

A.Ändern einer Zeichenfolge in Großbuchstaben

Im folgenden Beispiel wird die Eingabezeichenfolge 'abcDEF!@ 4' in Großbuchstaben geändert.

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

B.Suchen nach einer bestimmten Zeichenfolge

In diesem Beispiel wird gezeigt, wie die upper-case-Funktion in einer Suche verwendet wird, bei der nicht zwischen Groß- und Kleinschreibung unterschieden werden soll.

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 upper-case() function is used to make
--the search 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(upper-case(.), "FRAME")]')  = 1

Dies ist das Resultset.

ProductModelID Result

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

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>

Siehe auch

Verweis

XQuery-Funktionen für den xml-Datentyp