docs.intersystems.com
InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference

InterSystems SQL Reference
RIGHT
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


A scalar string function that returns a specified number of characters from the end (rightmost position) of a string expression.
Synopsis
{fn RIGHT(string-expression,count)}
Arguments
string-expression A string expression, which can be the name of a column, a string literal, or the result of another scalar function, where the underlying data type can be represented as any character type (such as CHAR or VARCHAR).
count An integer that specifies the number of characters to return from the ending (rightmost) position of string-expression.
Description
RIGHT returns count number of charactersfrom the end (rightmost position) of string-expression. RIGHT returnsNULL if passed a NULL value for either argument.
RIGHT can only be used as an ODBC scalar function (withthe curly brace syntax).
Examples
The following example returns the two rightmost characters of each name in the Sample.Person table:
SELECT Name,{fn RIGHT(Name,2)}AS MiddleInitial
     FROM Sample.Person
The following embedded SQL example shows how RIGHT handlesa count that is longer than the string itself:
   &sql(SELECT Name,{fn RIGHT(Name,40)}
     INTO :a,:b
     FROM Sample.Person)
   IF SQLCODE'=0 {
     WRITE !,"Error code ",SQLCODE }
   ELSE {
     WRITE !,a,"=original",!,b,"=RIGHT 40" }
No padding is performed.
See Also
LEFT LTRIM RTRIM


Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-08-16 06:44:53