Sunny Books
What we have

SQL Server Builtin String Functions

The followings are some common used String functions for SQL SERVER.

Function Description
ASCII (Character_Expression) returns the ASCII code of the given character expression
CHAR (integer_Expression) converts an int ASCII code to a character. The Integer_Expression should be between 0 and 255
LTRIM (Character_Expression) removes blanks on the left handside od the given character expression
RTRIM (Character_Expression) removes blanks on the right handside od the given character expression
LOWER (Character_EXpression) converts all the characters in the given Character_Expression to lowercase letters
UPPER (Character_EXpression) converts all the characters in the given Character_Expression to uppercase letters
REVERSE (any_string_expression) reveres all the characters in the given string expression
LEN (String_Expression) returns the count of total characters in the given string expression, excluding the blanks at the end of the expression
LEFT (character_expression, integer_expression) returns the specified number of characters from the left handside of the given character expression
RIGHT (character_expression, integer_expression) returns the specified number of characters from the right handside of the given character expression
CHARINDEX (expression_to_find, expression_to_search, start_location returns the starting position of the specified expression in a character string
SUNSTRING (expression, start, length) returns substring (part of the string) from the given expression

Examples

/* all capital letters */
DECLARE @start int
SET @start = 65
WHILE (@start<=90)
BEGIN
	PRINT CHAR(@start)
	SET @start = @start + 1
END

Returns A to Z
/* all small letters */
DECLARE @start int
SET @start = 97
WHILE (@start<=122)
BEGIN
	PRINT CHAR(@start)
	SET @start = @start + 1
END

Returns a to z
SELECT LEFT('ABCDEFG', 4)
Returns ABCD

SELECT RIGHT('ABCDEFG', 4)
Returns DEFG

SELECT CHARINDEX('@', 'sara@yahoo.com')
Returns 5

SELECT SUBSTRING('sara@yahoo.com', 6,9)
Returns yahoo.com

SELECT SUBSTRING('sara@yahoo.com', CHARINDEX('@', 'sara@yahoo.com')+1, 
LEN('sara@yahoo.com')-CHARINDEX('@', 'sara@yahoo.com') )
Returns yahoo.com
SUNWEB EXPERT