SQL UCASE, SQL UPPER 函数

SQL UCASE或者SQL UPPER函数用于将一个字符串转换为大写字母。在SQL Server中,使用UPPER函数。

SQL UCASE, SQL UPPER 语法

SELECT UCASE(字符串表达式) 
FROM 数据表名

或者在SQL Server中:

SELECT UPPER(字符串表达式) 
FROM 数据表名

SQL UCASE, SQL UPPER 范例

数据表: Employees

EmployeeId FirstName LastName Department
203 Mazojys Fxoj Finance
204 Jozzh Lnanyo Finance
205 Syllauu Dfaafk Finance
206 Gecrrcc Srlkrt Finance
302 Jssme Bdnaa Development
303 Dnnaao Errllov Development
304 Tyoysww Osk Development

我们想将部门名(Department)转换为大写字母:

SELECT EmployeeId, FirstName, LastName, UCASE(Department) AS Department
FROM Employees

结果会类似于:

EmployeeId FirstName LastName Department
203 Mazojys Fxoj FINANCE
204 Jozzh Lnanyo FINANCE
205 Syllauu Dfaafk FINANCE
206 Gecrrcc Srlkrt FINANCE
302 Jssme Bdnaa DEVELOPMENT
303 Dnnaao Errllov DEVELOPMENT
304 Tyoysww Osk DEVELOPMENT