Saturday, February 16, 2013

SQL SERVER LOWER String Function

SQL Server LOWER String function lowers the character Sequence.


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


Ex 2:  SELECT LOWER(RegionDescriptioN) FROM REGION
O/P:
eastern                                          
western                                          
northern                                         
southern                                        


Ex 3:  Lower each Product Name except first character in Products table(northwind)

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