Question

The script below is converting this KP 67962188CAB to this: Kp 67962188cab .

SELECT       
    LOWER(GENERICFIELDS.GFIELD2) AS GFIELD2 ,
    CONVERT(varchar(5),ORDE_.DROPTIME,108)
FROM 
    Drama_

I need part of the data in UPPER and part in LOWER. It should read this:

KP 67962188cab  

The KP part is in UPPER, but cab is in lower. How can I do this?

Was it helpful?

Solution

Use SUBSTRING or LEFT and RIGHT to split your string into parts, that you can cast to upper/lower case respectively, and then concatenate back together.

For example, if the last 3 letters of a string should always be lowercase, and the rest uppercase, do this:

SELECT UPPER(LEFT(MyField, LEN(MyField)-3)) + LOWER(RIGHT(MyField, 3)) AS MyField
FROM ...

For example, this will convert "aBcDe12345fGh" to "ABCDE12345fgh"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top