Pages

Sunday, 31 July 2011

String Functions in SQL Server.

1 comments
 
Tags : String Functions,Sql Server 2005,Sql Server 2008.

Hi Friends,in this article i would like to explain String Functions in SQL Server.

* LEN (string) - Returns the length of the given string.

For Example :

select len(Address) as Address from Employee


* LEFT (string, length) - Returns the specified number of characters from the beginning of the string.

For Example :

Select LEFT(Address,1) as Address from Employee


* RIGTH (string, length) - Returns the specified number of characters from the end of the string.

For Example :

Select RIGHT(Address,2) as Address from Employee


* REVERSE (string) - Returns the given string in reverse order.

For Example :

Select Reverse(Address) as Address from Employee


* UPPER (string) - Converts the given string into uppercase letters.

For Example :

Select UPPER(Address) as Address from Employee


* LOWER(string) - Converts the given string into lowercase letters.

For Example :

Select LOWER(Address) as Address from Employee


* SPACE (integer) - Returns the string with the specified number of space characters.

For Example :

Select SPACE(1) as Address from Employee



* LTRIM (string) - LTRIM function to return a character expression after removing leading spaces.

For Example :

Select LTRIM(Address) as Address from Employee


* RTRIM (string) - RTRIM function to return a character expression after removing trailing spaces.

For Example :

Select RTRIM(Address) as Address from Employee



* SUBSTRING (string, start, length) - Returns the specified number of characters from the string starting at the specified position.

For Example :

Select SUBSTRING (Address, 1, 4) as Address from Employee


Thank you...
Shout it

One Response so far.

  1. Anonymous says:

    Hi Dotnet Guru,

    Thanks for sharing this information...

Leave a Reply