- What is SQL NCHAR Function?
NCHAR function returns the Unicode character based on the number_code in the Unicode standard.
Syntax: NCHAR(Number code)
The above query returns the Z character which code is 90 in ASCII.
- What is SQL PATINDEX Function?
The PATINDEX functions returns the location of a pattern in a string. The search is not case-sensitive.
Syntax: PATINDEX(‘%S%’, string)
The above query returns 2 the position of y character from a string.
If we try to find the char position which is not available in the string then it will be return the 0 position always. Mentioned in above query.
- What is SQL REPLACE Function?
The REPLACE function replaces a sequence of characters in a string with another set of characters, not case-sensitive. Replace function contain three parameters.
Syntax: REPLACE(String1,String text to replace, Replacement string text)
The above query returns the string value where ‘o’ is Replace with ‘5’ and finally string value become “WWW.G55gle.C5m”.
- What is SQL STR() Function?
The STR Function return a string representation of a number.
STR function contain three parameters (i) Number values (ii) Length you want to display (iii) Decimal Places. Two parameters are optional.
The above query show 123.5 STR() function round of value returns 124.
The above query returns the 123.46 value. We defined in the STR Function that 7 values display and 2 means only 2 decimals. So actual value in string is (123.456,7,2) and finally after STR function 123.46.
If we define two parameters in STR function, then it will always return the round of value because decimal default value is 0.
- What is SQL STUFF() Function?
Stuff function allow us to replace the string value with new string or some string text with new one.
Stuff function contain four parameters STUFF(String,start position to replace string,Total charater replace, string text which you want to replace).
Syntax: STUFF(String,Int start position, Int total character replce,String replacement)
The above query show that STUFF Function allow to replace position started from 1 char and 4 character will be replace with “WWWW” string value.
- What is SQL SUBSTRING() Function?
The SUBSTRING functions allows you to extract a substring from a string.
SUBSTRING Contain three parameter
(ii) Integer Position Started
(iii)Integer for how much character to show
Syntax: SUBSTRING(String, Integer Start Position, Integer to display Characters)
The above query returns first 4 character of the string. We have mentioned in parameter 2nd parameter 1 which means start position 1 and third parameter is 4 which means display 4 characters from the start of String.
Thanks for reading the article.