STUFF and REPLACE.
STUFF (character expression, start, length, character expression)
Eg: SELECT STUFF('ABCDEF', 2, 3, 'JKLMN')
ResultSet
AJKLMNEF
What this STUFF Function will do is
1)Checks First two characters in the Character Expression(‘ABCDEF’)
2)Those two characters are BC in the Character Expression.
3)This starts count from B to D (Total Count 3)
4)So it removes BCD and Place JKLMN in that place.
5)So result set appears as AJKLMNEF
REPLACE:
REPLACE will also do the same with the Different way.
REPLACE (string_expression1, string_expression2, string_expression3)
Eg: SELECT REPLACE('ABCDEF','BCD','JKLMN')
ResultSet:
AJKLMNEF
The way REPLACE Works is:
1)First it checks for the BCD in ABCDEF
2)And Remove BCD and Place JKLMN in the place of BCD
3)So output look like as AJKLMNEF
Eg: SELECT STUFF('ABCDEF', 2, 3, 'JKLMN')
ResultSet
AJKLMNEF
What this STUFF Function will do is
1)Checks First two characters in the Character Expression(‘ABCDEF’)
2)Those two characters are BC in the Character Expression.
3)This starts count from B to D (Total Count 3)
4)So it removes BCD and Place JKLMN in that place.
5)So result set appears as AJKLMNEF
REPLACE:
REPLACE will also do the same with the Different way.
REPLACE (string_expression1, string_expression2, string_expression3)
Eg: SELECT REPLACE('ABCDEF','BCD','JKLMN')
ResultSet:
AJKLMNEF
The way REPLACE Works is:
1)First it checks for the BCD in ABCDEF
2)And Remove BCD and Place JKLMN in the place of BCD
3)So output look like as AJKLMNEF
Comments