SQL Server String FunctionsString functions are mainly used to change the case of strings,concatenate strings,reverse strings,extract various part of strings and perform many other types of string manipulation. In SQL Server there is a Several built-in string functions to perform string manipulations.All below functions takes string input value and return a string or numeric value. ASCII : Returns the ASCII code value of a character(leftmost character of string).
UNICODE : UNICODE function works just like ASCII function,except returns Unicode standard integer value. UNICODE could be useful if you are working with international character sets.
LOWER : Convert character strings data into lowercase.
UPPER : Convert character strings data into Uppercase.
LEN : Returns the length of the character string.
REPLACE : Replaces all occurrences of the second string(string2) in the first string(string1) with a third string(string3).
LEFT : Returns left part of a string with the specified number of characters counting from left.LEFT function is used to retrieve portions of the string.
RIGHT : Returns right part of a string with the specified number of characters counting from right.RIGHT function is used to retrieve portions of the string.
LTRIM : Returns a string after removing leading blanks on Left side.(Remove left side space or blanks)
RTRIM : Returns a string after removing leading blanks on Right side.(Remove right side space or blanks)
REVERSE : Returns reverse of a input string.
REPLICATE : Repeats a input string for a specified number of times.
SPACE : Returns a string of repeated spaces.The SPACE function is an equivalent of using REPLICATE function to repeat spaces.
SUBSTRING : Returns part of a given string. SUBSTRING function retrieves a portion of the given string starting at the specified character(startindex) to the number of characters specified(length).
STUFF : Deletes a specified length of characters and inserts another set of characters at a specified starting point. STUFF function is useful to inserts a set of characters(string2) into a given string(string1) at a given position.
CHARINDEX : Returns the starting position of the specified string(string1) in a character string(string2).
PATINDEX : PATINDEX function works very similar to CHARINDEX function.PATINDEX function returns the starting position of the first occurrence of a pattern in a specified string, or zeros if the pttern is not found. Using PATINDEX function you can search pattern in given string using Wildcard characters(%).The % character must come before and after pattern.
|
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment