Chinese and English character hybrid treatment method

xiaoxiao2021-03-06  84

1, TXT file is imported into SQL

303410001401 ??????? 600 lang 4-t Guangdong IG? 0220 ??? 011840628900000 ?? bpo303410001501 ??????? 600 landau in ER? 0220 ??? 011840628900000 ?? bpo303410001601 ?????? ? 600 LANG 6-T Han IG? 0220 ??? 011840628900000 ?? BPO

There is this TXT file to import SQL, there is a fixed data format, which is integrated into a column due to no significant definition, and then intercepts the separation in SQL, and there is the problem:

The length of the data structure is a single-byte length, but only one of SUBString () in SQL is only one bit, in some requirements, because Chinese characters are free, if only one will affect the correctness of the data.

Workaround: Cast (Substring (Cast (Cast), 39, 4) AS Char (18)) AS TIME_ID

That is to transfer the field to a Varbinary type. This Chinese characters are also 2 digits, and the interception is satisfied to meet the fixed format, and then turn back the character.

2, SQL table leads to TXT

Use CAST (????? as char (20))

3, take the length

Len () Chinese characters only count 1

Use Datalength () Chinese characters to count 2

转载请注明原文地址:https://www.9cbs.com/read-124033.html

New Post(0)