SQL Server String Functions |
|
Function |
Description |
ASCII |
Returns the ASCII
value for the specific character |
CHAR |
Returns the
character based on the ASCII code |
CHARINDEX |
Returns the
position of a substring in a string |
CONCAT |
Adds two or more
strings together |
Concat with + |
Adds two or more
strings together |
CONCAT_WS |
Adds two or more
strings together with a separator |
DATALENGTH |
Returns the
number of bytes used to represent an expression |
DIFFERENCE |
Compares two
SOUNDEX values, and returns an integer value |
FORMAT |
Formats a value
with the specified format |
LEFT |
Extracts a number
of characters from a string (starting from left) |
LEN |
Returns the
length of a string |
LOWER |
Converts a string
to lower-case |
LTRIM |
Removes leading
spaces from a string |
NCHAR |
Returns the
Unicode character based on the number code |
PATINDEX |
Returns the
position of a pattern in a string |
QUOTENAME |
Returns a Unicode
string with delimiters added to make the string a valid SQL Server delimited
identifier |
REPLACE |
Replaces all
occurrences of a substring within a string, with a new substring |
REPLICATE |
Repeats a string
a specified number of times |
REVERSE |
Reverses a string
and returns the result |
RIGHT |
Extracts a number
of characters from a string (starting from right) |
RTRIM |
Removes trailing
spaces from a string |
SOUNDEX |
Returns a
four-character code to evaluate the similarity of two strings |
SPACE |
Returns a string
of the specified number of space characters |
STR |
Returns a number
as string |
STUFF |
Deletes a part of
a string and then inserts another part into the string, starting at a
specified position |
SUBSTRING |
Extracts some
characters from a string |
TRANSLATE |
Returns the
string from the first argument after the characters specified in the second
argument are translated into the characters specified in the third argument. |
TRIM |
Removes leading
and trailing spaces (or other specified characters) from a string |
UNICODE |
Returns the
Unicode value for the first character of the input expression |
UPPER |
Converts a string
to upper-case |
CREATE TABLE STRING_FUNT(CHAR1 VARCHAR(10),CHAR2 VARCHAR(10));
INSERT INTO STRING_FUNT VALUES('RAM','ABC'),('SHYAM','ABD'),
('RADHA','ABE');
SELECT * FROM STRING_FUNT;
SOME EXAMPLE OF IMPORTANT STRING FUNCTION.
LENGTH FUNCTION
SELECT LEN(CHAR1) FROM STRING_FUNT;
REPLACE FUNTION
SELECT REPLACE(CHAR1,'RAM','RAJ') FROM STRING_FUNT;
REVERESE FUNCTION
SELECT REVERSE(CHAR1) FROM STRING_FUNT WHERE CHAR2 LIKE 'ABD';
LOWER FUNCTION
SELECT LOWER(CHAR2) FROM STRING_FUNT;
0 Comments
Refer to a specific part of their comment that you appreciate. Relate to them if you can.