SELECT RIGHT('HELLO WORLD', 3); SELECT LEFT('HELLO WORLD', 3); Here's the result: As you can see, the RIGHT function has expectedly taken the last three characters of the string passed into it, and the LEFT function has taken the first three. Pretty simple!
The RIGHT function returns a string that consists of the specified number of rightmost bytes or specified string unit from a string.
The following example returns the five rightmost characters of the first name for each contact. USE AdventureWorks2008R2; GO SELECT RIGHT(FirstName, 5) AS 'First Name' FROM Person.Person WHERE BusinessEntityID < 5 ORDER BY FirstName; GO ...
The RIGHT function returns a string that consists of the specified number of rightmost bytes or specified string unit from a string.
When using SC collations, the RIGHT function counts a UTF-16 surrogate pair as a single character. For more information, see Collation and Unicode Support.ExamplesA: Using RIGHT with a columnThe following example returns the five rightmost characters of the first name for each person in the ...
01004 String data, right truncated The buffer *InfoValuePtr was not large enough to return all the requested information. Therefore, the information was truncated. The length of the requested information in its untruncated form is returned in *StringLengthPtr. (Function returns SQL_SUCCESS_WITH_INF...
When using SC collations, the RIGHT function counts a UTF-16 surrogate pair as a single character. For more information, see Collation and Unicode Support. Examples A: Using RIGHT with a column The following example returns the five rightmost characters of the first name for each person in the...
I. Use EXECUTE with a user-defined functionThe following example executes the ufnGetSalesOrderStatusText scalar user-defined function in the AdventureWorks2022 database. It uses the variable @returnstatus to store the value returned by the function. The function expects one input parameter, @Status....
When using SC collations, the RIGHT function counts a UTF-16 surrogate pair as a single character. For more information, seeCollation and Unicode Support. Examples A: Using RIGHT with a column The following example returns the five rightmost characters of the first name for each person in the...
String function or operatorWith an SCA collationWithout an SCA collation CHARINDEXLENPATINDEX The UTF-16 surrogate pair is counted as a single code point. The UTF-16 surrogate pair is counted as two code points. LEFTREPLACEREVERSERIGHTSUBSTRINGSTUFF These functions treat each surrogate pair as a ...