Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SqlServer gets the sql statement of lowercase letters in a string

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Sometimes we will intercept some special things in the string, such as uppercase and lowercase letters, module numbers, Chinese characters, numbers, and so on. Today, we will introduce a way to get lowercase letters (also uppercase letters) in a string.

DECLARE @ s VARCHAR (MAX) = 'AbcdEf Ool'-string to be intercepted DECLARE @ temp VARCHAR (MAX) =''- temporary variable SELECT @ temp=@temp+SUBSTRING (ch, sv.number, 1) FROM (SELECT @ s AS ch) t CROSS APPLY [master] .dbo.spt _ values AS sv WHERE sv.type = 'P'AND sv.number BETWEEN 1 AND LEN (ch) AND ASCII (SUBSTRING (ch, sv.number) 1) BETWEEN ASCII ('a') AND ASCII ('z') SELECT @ temp

The results are as follows:

So we get lowercase letters, and of course we can get uppercase letters:

SELECT @ temp=@temp+SUBSTRING (ch, sv.number, 1) FROM (SELECT @ s AS ch) t CROSS APPLY [master] .dbo.spt _ values AS sv WHERE sv.type ='P' AND sv.number BETWEEN 1 AND LEN (ch) AND ASCII (SUBSTRING (ch, sv.number, 1) BETWEEN ASCII ('A') AND ASCII ('Z') SELECT @ temp

The results are as follows:

Flexible grasp, according to the needs of the application.

Summary

The above is the realization sentence of SqlServer to get the lowercase letters of the string introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report