SQL String Functions

Introduction

SQL Server String functions are scalar functions that perform an operation on a string input values and return a string or numeric value. SQL Server String built-in function. In this section, we cover string function seen in SQL. Different RDBMS may employ different string functions.

List Of String Function
  1. ASCII
  2. CHAR
  3. REVERSE
  4. UPPER
  5. LEFT
  6. LEN
  7. LOWER
  8. LTRIM
  9. NCHAR
  10. REPLACE
Explanation Of All Above Functions
  1. ASCII

    Return the ASCII code value of the left most character of the current string. ASCII() works for characters with numeric values from 0 to 255. Here’s Figure 1.1.

    ASCII

  2. CHAR

    Convert an int ASCII code to character. Null Values are skipped. It is opposite to ASCII() function. Here’s Figure 1.2.

    CHAR

  3. REVERSE

    Return the string with the order the characters reversed. See reverse string in Figure 1.3.

    REVERSE

  4. UPPER

    Returns a UPPER case string. Here’s Figure 1.4 and you can see lower string value converted to upper case string.

    UPPER

  5. LEFT

    Returns the left part of a character string with the specified number of characters. Here’s Figure 1.5 Left() function two arguments:
    1. String
    2. Length of string

    LEFT

  6. LEN

    Returns the number of characters, instead of the number of bytes of the specified string. Length of string in Figure 1.6.

    LEN

  7. LOWER

    Returns a character string after converting uppercase string to lower strings. Here’s string is UPPER case string To lower case string.

    LOWER

  8. LTRIM

    Remove leading blanks spaces in string.

    LTRIM

  9. NCHAR

    Return specified integer code defined by Unicode standard. Same as Char() function. (Figure 1.9).

    NCHAR

  10. REPLACE

    Replace one string to second string. Replace() performs a case-sensitive match when searching for form_str.

    REPLACE