String Function in SQL Server

String Function

String function are built in function that operate on string type of data .the string function available in sql server are as follows.
 

Function

Use

Syntax

Output

ASCII(Char)

Used to give ascii value of given character

ASCII(‘A’)

97

Char(n)

It takes ascii values as argument and returns character for that ascii value

Char(65)

A

Left(n,string)

Used to extract ‘n’ no of character from bit of given string

Left(‘Microsoft’,4)

Micr

Right(String,n)

Used to extract ‘n’ no of character from right of the given string

Right(‘Microsoft’,4)

Soft

Substring(string,p,n)

Used to extract ‘n’ no of characters starting from  position ‘p’ from the given string

Substring(‘Microsoft,3,4’)

cros

Ltrim(string)

Used to delete all the blank spaces on left of given string

 

 

RTrim(strin g)

Used to delete all the blank spaces on right of given string

 

 

Stuff(string1,p,n,string2)

Used to replace ‘n’ no of char starting from position ‘p’ in the string string with string2

Stuff(‘Notepad,1,4,’word’)

Wordpad

Upper(string)

Used to convert given str to upper case.

Upper(‘microsoft’)

MICROSOFT

Lower(string)

Used to convert given str to Lower case.

Lower(‘MICROSOFT’)

microsoft

Len(string)

Used to get no of character in given string

Len(‘microsoft’)

9