Funzioni su valori stringa - upper-case

Si applica a:SQL Server

Questa funzione converte ogni carattere in $arg nell'equivalente maiuscolo. La modalità di conversione dei caratteri nell'equivalente maiuscolo viene specificata dalla conversione binaria di maiuscole e minuscole di Microsoft Windows per i punti di codice Unicode. Questo standard è diverso dal mapping per lo standard dei punti di codice Unicode.

Sintassi

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

Argomenti

Termine Definizione
$arg Valore della stringa da convertire in lettere maiuscole.

Osservazioni:

Se il valore di $arg è vuoto, viene restituita una stringa di lunghezza zero.

Esempi

R. Conversione di una stringa in lettere maiuscole

Nell'esempio seguente la stringa di input 'abcDEF!@4' viene modificata in lettere maiuscole.

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

B. Ricerca di una stringa di caratteri specifica

In questo esempio viene illustrato come utilizzare la funzione upper-case per eseguire un ricerca senza distinzione tra maiuscole e minuscole.

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  

Questo è il set di risultati.

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>

Vedi anche

Funzioni XQuery per il tipo di dati XML