Replacement of special characters such as tabs, spaces, and carriage returns in sqlserver field data [Figure]

In a computer, all data must be represented by binary numbers during storage and operations, including 52 letters (including uppercase), numbers, and commonly used symbols (for example, #, @, etc.). For specific binary numbers to represent which symbol, everyone must use the same encoding rules. The relevant United States standardization organization has issued ASCII encoding (American Standard Code for Information Interchange).
SELECT CHAR(36);
--The displayed result is the syntax format of the replacement function replace() in $SQL as follows: REPLACE (stringexpression, stringpattern, stringreplacement)
stringexpression The string expression to be searched.
stringpattern is the substring to be searched, and cannot be an empty string ('').
stringreplacement Replacement string.
How to use ASCII encoding to replace special characters such as spaces?
Replacement of special characters such as tabs, spaces, and carriage returns in sqlserver field data [Figure]
--Remove the space UPDATE [dbo].[Online training qualified personnel] set ID number=REPLACE(ID number,char(32),'')--Remove TABUPDATE [dbo].[Online training qualified personnel] set ID number=REPLACE(ID number,char(32),'') ASCII decimal code (corresponding) abbreviated character (or function/interpretation) is as follows:
0 NUL (null) empty character 1 SOH (start of headline) headline start 2 STX (start of text) text start 3 ETX (end of text) text end 4 EOT (end of transmission) transmission end 5 ENQ (enquiry) request 6 ACK (acknowledge) received notification 7 BEL (bell) bell 8 BS (backspace) backspace 9 HT (horizontal tab) horizontal tab 10 LF (NL line feed, new line) line feed 11 VT (vertical tab) vertical Tab 12 FF (NP form feed, new page) Form feed key 13 CR (carriage return) Enter key 14 SO (shift out) No need to switch 15 SI (shift in) Enable switch 16 DLE (data link escape) Data link Path escape 17 DC1 (device control 1) device control 118 DC2 (device control 2) device control 219 DC3 (device control 3) device control 320 DC4 (device control 4) device control 421 NAK (negative acknowledge) Rejection 22 SYN ( synchronous idle) Synchronous idle 23 ETB (end of trans. block) End of transmission block 24 CAN (cancel) Cancel 25 EM (end of medium) Medium interruption 26 SUB (substitute) Substitute 27 ESC (escape) Escape (overflow) 28 FS (file separator) File separator 29 GS (group separator) Group symbol 30 RS (record separator) Record separator 31 US (unit separator) Unit separator 32 space
The sample codes of TAB tab char(9), line feed char(10), enter key char(13), space char(32) in the replacement field are as follows:
UPDATE [dbo ].[Online training qualified personnel] SET ID number = REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (ID number, CHAR (10 ),'' ), CHAR (13 ),'' ), CHAR (10) + CHAR (13 ),'') ,CHAR (9),''),CHAR (32),'')

简介:SQL Server是由Microsoft开发和推广的关系数据库管理系统(DBMS),它最初是由Microsoft、Sybase和Ashton-Tate三家公司共同开发的,作文https://www.isanxia.com并于198年推出了第一个OS/2版本。Microsoft SQL Server近年来不断更新版本,1996年,Microsoft 推出了SQL Server 6.5版本;1998年,SQL Server 7.0版本和用户见面;SQL Server 2000是Microsoft公司于2000年推出,目前最新版本是2019年份推出的SQL SERVER 2019。

sqlserver queries whether all fields of a table contain tabs, line feeds, and carriage returns:
tab: CHAR(9)
line feed: CHAR(10)
carriage return: CHAR(13)
select'SELECT COUNT() FROM Table name where CHARINDEX(CHAR(9),"'+SysColumns.name+'")>0 union all'
from sysobjects inner join SysColumns on sysobjects.id=SysColumns.id
where sysobjects.name='table name' select'SELECT
COUNT () FROM table name where CHARINDEX(CHAR(10),"'+SysColumns.name+'")>0 union all'
from sysobjects inner join SysColumns on sysobjects.id=SysColumns.id
where sysobjects.name='table name'
select 'SELECT COUNT() FROM table name where CHARINDEX(CHAR(13),"'+SysColumns.name+'")>0 union all'
from sysobjects inner join SysColumns on sysobjects.id=SysColumns.id
where sysobjects.name='表名'**

Guess you like

Origin blog.51cto.com/14938467/2539459