T-SQL String Function
In T-SQL, String function is applied on string value and returns the numeric data or the string value.
Type of string function with the help of an example is given below:
ASCII code value comes as the output of character expression.
The query will give the ASCII value of the character.
The character will come like an output for the ASCII code or integer.
The below query generates the character of the integer.
Using NCHAR (), Unicode character of any integer comes in the output that we have used.
The query returns the Unicode character of the integer.
The starting position for any search expression will come as an output in the string expression.
The following query will generate the starting position of 'A' character in the string 'JAVATPOINT.'
LEFT () is used to return the left part of the string till the specified number of characters of the given string.
The query returns the string as mentioned four numbers of characters for the string 'INDIA'.
It returns the right part of any string till the specified number of characters as output for the input string.
The query will give the 'DIA' string as mentioned three characters for input string 'INDIA.'
SUBSTRING is the part of a string that is based on the start position, and the length value will come like the output of a string.
The given command will give 'FORM,' 'DIA,' 'EEN' strings which we have mentioned (1,3), (3,3), and (2,3) respectively, and then the length values as strings' world. For ',' India 'and' QUEEN'.
LEN() is the number of characters that come as the output of the string expression.
The query returns 4 for the 'JAVA' string.
The Lowercase string comes as an output of the string data.
The query gives the 'sqlserver' for the 'SQL' character data.
Uppercase string is returned as the output of the string data.
The query gives the 'JAVATPOINT' for the 'javatpoint' character data. It changes the string in uppercase.
The String expression will return as an output for string data after removing the leading blanks in the LTRIM ().
The query gives the 'TUTORIAL' for the ' TUTORIAL' character data.
RTRIM () in String expression returns the output for the given string data after removing the blanks.
The query gives the 'ASIA' for the 'ASIA ' character data.
The string expression for the given string data comes as output after replacing all the frequencies of the character with another one.
The query returns the 'KNDKA' string for the 'ASIA' string data.
REPLICATE() is used to repeat string expression, which gives the output of string data for multiple times.
Reverse string expression comes as the output for the string operation.
The query gives the 'LAPTOP' string for the 'POTPAL' string data. REVERSE() will reverse our string.
SOUNDEX () returns four-character (SOUNDEX) code to evaluate one or more characters.
The query gives the 'S530' for the 'Twist' and 'Twyst' strings.
The Integer value comes as an output of two input expressions.
The following query gives 4 for the 'Michal,' 'Micaal' expressions.
Note - If the output is 0, it indicates the weak similarity between the expressions.
SPACE String is returned as output with the number of spaces.
The query will give the 'JAVATPOINT HAS CONTENTS.'
The expression of a string returns the output of any string data after the original character is changed to the length specified with style.
The query will return the 'MNOPQR' string according to the first character, and length is given for the 'ABCDEFGH' string data as 2 and 4 and 'IJK' as the targeted string.
Character data is returned as the output of the numeric data.
The query will give the 187.37 for the given 156.901 based on the length as eight and decimal as 5.
In UNICODE () character, integer value comes as the output of the first character of the given expression.
The following query returns 56 for the 'PHP' expression.
The string would come as an output with the delimiter.
The query will give the "SHYAM" for the given 'SHYAM' string as we specified a double quote in the delimiter.
In PATINDEX, starting position of the first occurrence of the expression where we specified 'N' view is required.
The following query will give 1 for 'ASIA.'
In FORMAT(), given expression come as output with the changed format.
The following query gives the ' Friday, DECEMBER 16, 2019' for the getdate() function as per specified format with 'D' refers to the weekday name.
In CONCAT (), the single string has come as the output after concatenating the given parameter values.
The below query gives the 'X, Y, Z' for the given parameters.