A~Z :65~90
a~z :97~122
0~9 : 48~57
-Chinese character unicode encoding range: [0x4e00,0x9fa5] (or decimal [19968,40869])
SELECT *
FROM dbo.person
WHERE UNICODE(zz) BETWEEN 19968 AND 40869
or
WHERE UNICODE(zz) BETWEEN 0x4e00 AND 0x9fa5
We often use it to determine whether a character or string contains Chinese, English, special symbols and so on. At this time, you can determine the type of a character by judging the range of Unicode. Of course, the Unicode code can be judged directly, but in view of habits, the following provides the numeric range corresponding to the Unicode code. After all, the nature of characters is stored and encoded through binary.
Chinese characters: [0x4e00,0x9fa5] (or decimal [19968,40869])
Numbers: [0x30,0x39] (or decimal [48, 57])
Lower case letters: [0x61,0x7a] (or decimal [97, 122])
uppercase Letters: [0x41,0x5a] (or decimal [65, 90])
Others: divide all
1.SQL trim() function to remove the double spaces
ltrim() removes the left space and rtrim() removes the right space. Remove the double spaces is select ltrim(rtrim(field))
2.replace() function to replace characters
According to ASCII code
select char(64) corresponds to @ then select replace('[email protected]',char(64),'d')
Result: abcd163.com
Remove the tab as select replace('field',char(9),'')
Remove the spaces as select replace('field',char(32),'')
Remove the replacement behavior select replace('field',char(10),'').
SqlServer obtains the SQL statement of lowercase letters in the
string. SQL string interception (SubString)
Function: Return the substring of the length specified by the third parameter from the position specified by the second parameter in the first parameter.
Sometimes we will intercept some special things in the string, such as uppercase and lowercase letters, modulus, Chinese characters, numbers, etc., today we will introduce a way to get the lowercase letters (also uppercase letters) in the string, and write directly. :
Copy Code
DECLARE @s VARCHAR (MAX) = ' AbcdEf Aoao' - strings to be taken
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)) the BETWEEN the ASCII ( 'a') the AND the ASCII ( 'Z')
the SELECT @temp
copy the code
so we obtained a lowercase letter, of course, we can also get capital 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