Sunday, February 17, 2013

SQL SERVER UPPER String Function

SQL SERVER UPPER String Function

SQL Server UPPER String function uppers the alphabets into upper case.

For ex:     select UPPER('hello')   ->  HELLO


Ex 2:  SELECT UPPER(RegionDescriptioN) FROM REGION
O/P:
EASTREN
WESTREN
NORTHERN
SOUTHERN


Ex 3:  UPPER  FIRST CHARACTER & MAKE REMAINING LOWER

Here is the Logic
             1.Find ASCII value of first character in ProductName
             2.get Substring from position 2 to end of the String
             3.Lower the String from Position 2 to end  of the String.
             4
SELECT UPPER(char(ascii(productname)))+lower(SubString(productname,2,len(productname))) [Product Name] FROM PRODUCTS

Product Name
Alice mutton
Aniseed syrup
Boston crab meat
Camembert pierrot
Carnarvon tigers
Chai
Chang
Chartreuse verte
Chef anton's cajun seasoning
Chef anton's gumbo mix
Chocolade


Tags:SQL SERVER LOWER String Function,SQL Server Upper Function,SQL Server ascii string function,SQL Server char function, SQL Server SubString function,Make First character Upper remaining lower in SQL Server.

No comments:

Post a Comment