SQL LOWER和SQL UPPER功能概述

This article gives an overview of SQL UPPER function and SQL LOWER function to convert the character case as uppercase and lowercase respectively.

本文概述了将字符大小写分别转换为大写和小写SQL UPPER函数和SQL LOWER函数。

介绍 (Introduction )

Suppose you have an online shopping website. Customers visit the website and provide their necessary information while creating a login account. Each customer provides few mandatory information such as first name, last name, email address and residential address. Each customer is different so you cannot expect a similar format for all inputs.

假设您有一个在线购物网站。 客户访问网站并在创建登录帐户时提供他们的必要信息。 每个客户仅提供一些必填信息,例如名字,姓氏,电子邮件地址和居住地址。 每个客户都是不同的,因此您不能期望所有输入都使用相似的格式。

For example, you get the following entries in your SQL table. We do not see all words following a consistent pattern. It does not look good as well if you have to share the report daily to higher management for all newly enrolled customers.

例如,您在SQL表中获得以下条目。 我们没有看到所有单词都遵循一致的模式。 如果您必须每天向所有新注册客户的高级管理人员共享报告,则情况也不太好。

In the following table, you can see the different types of inputs from different customers. For example, in [First Name] column, we have Raj (First character capital), sonu (all small case characters) and PAUL (capital letters).

在下表中,您可以看到来自不同客户的不同类型的输入。 例如,在[名字]列中,我们有Raj(大写字母大写),sonu(所有小写字母)和PAUL(大写字母)。

First Name

Last Name

Email address

Residential address

Raj

Gupta

[email protected]

140, high street, la

sonu

Kumar

[email protected]

10,KING STREET, GA

PAUL

SMITH

[email protected]

20,New Market, SA

名字

电子邮件地址

居住地址

拉吉

古普塔

[email protected]

洛杉矶高街140号

声纳

库玛

[email protected]

乔治亚国王街10号

保罗

史密斯

保罗·史密斯@ Abc.com

20,New Market,SA

You might think of a question at this point – Is it possible to covert the character case in SQL Server to an appropriate format.

您可能会想到一个问题–是否可以将SQL Server中的字符大小写转换为适当的格式。

Yes, it is quite possible. Let’s explore a few available scenarios in the further section of this article.

是的,这很有可能。 让我们在本文的后续部分中探讨一些可用的方案。

SQL UPPER函数 (SQL UPPER Function)

We use SQL UPPER function to convert the characters in the expression into uppercase. It converts all characters into capital letters.

我们使用SQL UPPER函数将表达式中的字符转换为大写。 它将所有字符转换为大写字母。

The syntax of SQL Upper function is:

SQL Upper函数的语法为:

SELECT UPPER(expression) FROM [Source Data]

Let’s use some examples for this function and view the output.

让我们使用此函数的一些示例并查看输出。

示例1:在单个单词中对所有小写字符使用UPPER功能 (Example 1: Use UPPER function with all lower case characters in a single word)

SELECT UPPER('sqlshack');

It gives the following output.

它给出以下输出。

SQL UPPER function

示例2:对表达式中的所有小写字符使用UPPER函数 (Example 2: Use UPPER function with all lower case characters in an expression)

In this example, we use a string with Upper function, and it converts all letters in the string to uppercase.

在此示例中,我们使用具有Upper函数的字符串,并将字符串中的所有字母都转换为大写。

SELECT UPPER('learn sql server with sqlshack');

Output: It converts all characters for a string.

输出:它将所有字符转换为字符串。

Use UPPER function with all lower case characters in an expression

示例3:将SQL UPPER函数与表达式中的混合大小写(小写和大写字母组合)字符一起使用 (Example 3: Use an SQL UPPER function with mix case (combination of the lower and upper case) characters in an expression

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值