Forum Moderators: open

Message Too Old, No Replies

Upper Case

         

stevelibby

11:01 am on Mar 31, 2005 (gmt 0)

10+ Year Member



Hi all
How can convert this query to output all in upper case or even to lower case? ideally have first letter capitalized:

SELECT DISTINCT Usedcars.Make
FROM Usedcars
ORDER BY Usedcars.Make;

using MsSql!

mattglet

12:34 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SELECT DISTINCT (UPPER(LEFT(Usedcars.Make, 1)) + LOWER(RIGHT(Usedcars.Make, LENGTH(Usedcars.Make) - 1))) as Make
FROM Usedcars
ORDER BY Usedcars.Make;

That should capitalize the first letter, and lowercase the rest. I didn't test it, so come back if you have any errors you can't get.

stevelibby

1:44 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



yes it came back with an error

topr8

2:01 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



alternatively within the asp you can use UCASE or LCASE to convert the string

eg

newstring=UCASE('oldstring')

CaseyRyan

2:45 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



Taking what Matt started, I added a confirmation that the length of the string supported the substring commands. I used Northwind to test it.

SELECT CASE
WHEN (LEN(LastName)>1) THEN UPPER(LEFT(LastName,1)) + LOWER(RIGHT(LastName,LEN(LastName)-1))
ELSE UPPER(LastName)
END
FROM Employees
ORDER BY LastName

-=casey=-

mattglet

3:00 pm on Mar 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Steve-

If you get an error, try pasting it so we can troubleshoot...