Delen via


Functies voor tekenreekswaarden - hoofdletters

van toepassing op:SQL Server-

Met deze functie wordt elk teken in $arg geconverteerd naar het equivalent van hoofdletters. De binaire hoofdletterconversie van Microsoft Windows voor Unicode-codepunten geeft aan hoe tekens worden geconverteerd naar hoofdletters. Deze standaard is anders dan de toewijzing voor standaardcodepuntstandaard Unicode.

Syntaxis

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

Argumenten

Term Definitie
$arg De tekenreekswaarde die moet worden geconverteerd naar hoofdletters.

Opmerkingen

Als de waarde van $arg leeg is, wordt een tekenreeks met lengte nul geretourneerd.

Voorbeelden

Een. Een tekenreeks wijzigen in hoofdletters

In het volgende voorbeeld wordt de invoertekenreeks 'abcDEF!@4' gewijzigd in hoofdletters.

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

B. Zoeken naar een specifieke tekenreeks

In dit voorbeeld ziet u hoe u de functie hoofdletters gebruikt om een hoofdlettergevoelige zoekopdracht uit te voeren.

USE AdventureWorks2022;
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  

Dit is de resultatenset.

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>

Zie ook

XQuery-functies op basis van het xml-gegevenstype