DATABASE & SQL/PLSQL

adplus-dvertising
Using String Functions
Previous Home Next

This function use to format data that will meet specific requirements. Mostly they are used with the char and varchar data types. It used for implicit convert data to char to varchar.

SELECT function_name (parameter)

function_name is the name of the string function. parameter are required parameters for the string function.

Function nameParametersExampleDescription
ASCII(character_expression)SELECT ASCII ('ADI')Return 65 the ASCII code of the leftmost character 'A'
CHAR(integer_expression)SELECT CHAR (65)Return A the character equivalent of the ASCII code value
CHARINDEX('pattern', expression)SELECT CHARINDEX ('O','HELLO') (65)Returns 5, the standing position of the specified pattern in the expression
SOUNDEX(character_expression) SELECT SOUNDEX ('ADITYA')Return the four character code to compare the string
DIFFERENCE(character_expression1, character_expression2)SELECT DIFFERENCE ('ADITYA','ADI')Difference function compare the SOUNDEX value of two string and return a value from 0 to 4. The value 4 is best match.
LEFT(character_expression, integer_expression)SELECT LEFT ('ADITYA','4')Return 'ADIT', which is the part of character string equal in size to the integer_expression character from the left
LEN (character_expression)SELECT LEN ('ADITYA')Return 6, the no of character in the (character_expression)
LOWER(character_expression)SELECT LOWER ('ADITYA')Return 'aditya', after the converting (character_expression) to the lower case
LTRIM (character_expression) SELECT LTRIM (' ADITYA')Return 'ADITYA' without leading spaces. It removes leading blanks from the character expression
PATINDEX("%pattern%, expression")SELECT PATINDEX ('%TY%','ADITYA')Return 4, the standing position of the first occurrence of the pattern in the specified expression, or zero if pattern is not found
REVERSE(character_expression)SELECT REVERSE ('ADITYA')Return 'AYTIDA' , the reverse of the (character_expression)
RIGHT(character_expression, integer_expression)SELECT RIGHT ('ADITYA',4)Return 'ITYA' , the part of the character string.
RTRIM(character_expression)SELECT LTRIM ('ADITYA ')Return 'ADITYA' without leading spaces. It removes leading blanks from the character expression
SPACE(integer_expression)SELECT 'ADITYA'+SPACE(2)+'TIWARI'Returns 'ADITYA TIWARI'. Two space are inserted between the first and second word
STR(float_expression, [length,[decimal]])SELECT STR (123.45,6,2) Return 4, the standing position of the first occurrence of the pattern in the specified expression, or zero if pattern is not
STUFF(character_expression1, start, length,character_expression2)SELECT STUFF ('Aditya',2,3,'s')Return 'Asya'. It delete length characters from character_expression1 from the start and then inserts character_expression2 into character_expression1 at the start position
SUBSTRING(expression, start, length)SELECT SUBSTRING ('Aditya',2,3)Returns 'dit', which is part of a character string. It returns length character from the start position of the expression
UPPER(character_expression)SELECT UPPER ('aditya')Return 'ADITYA', after the converting (character_expression) to the upper case
Previous Home Next