1. Left ()
Left (<CHARACTER_EXPRESSION>, <integer_expression>)
Returns the integer_expression character from the left of character_expression.
[SQL]View PlainCopy
- Select Left (' abcdef ', 3)
[SQL]View PlainCopy
- --abc
2.charindex ()
CHARINDEX (< ' substring_expression ';, <expression>)
Returns the beginning of the occurrence of a specified substring in a string.
Where substring _expression is the character expression to look for, expression can be a string or a column name. If no substring is found, a value of 0 is returned.
This function cannot be used with text and image data types.
[SQL]View PlainCopy
- Select CHARINDEX (' CD ',' ABCDEFG ') --3
- Select CHARINDEX (' ac ',' ABCDEFG ') --0
3.stuff ()
[SQL]View PlainCopy
- Select Stuff (' abcde ', 2,3,' mmmm ')
[SQL]View PlainCopy
- --Ammme
--by removing the three characters from the second position (character B) in the first string (ABCDE),
--then insert the second string at the beginning of the deletion, creating and returning a string.
Use of the SQL Server function left (), charindex (), Stuff ()