简体   繁体   中英

Changing Case of Strings (Lower to Upper) in SQL Server

I have 2 databases, one with lowercase data and another with uppercase data.

DECLARE @NAME VARCHAR(40)
SELECT @NAME = UPPER(SELECT NAME FROM DELETED)

By executing SELECT NAME FROM DELETED , I am selecting data that is lower case.

By executing SELECT @NAME = UPPER(SELECT NAME FROM DELETED) , I would want to select uppercase data on the query inside the UPPER().

Question is can I use the UPPER() with the SELECT, like the query above?

How about

SELECT UPPER(NAME) FROM DELETED

instead of

UPPER(SELECT NAME FROM DELETED)

采用

SELECT @pNAME = UPPER([NAME]) FROM DELETED

You'll need an extra pair of brackets

Select @NAME = UPPER((SELECT NAME FROM DELETED));

(Not that I'd do it that way, see Lukas's answer for a better approach).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM