문제

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?

도움이 되었습니까?

해결책

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"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top