SQL minus Spaces

Source: Internet
Author: User

Tag: HID state failed repeatedly executed ALC check perform modify image

First, the problem description:

The field nvarchar type in the database holds the following data:

' 3.3x10 '

Second, the solution:

--Test Cases
CREATE TABLE #temp
(NAME NVARCHAR () null)
INSERT into #temp select Fecalcoliform from waterquality
SELECT * FROM #temp

Update #temp Set Name=replace (Name, ' ', '); ---1
Update #temp Set Name=replace (Name, ' ', '); ---2
Update #temp Set Name=replace (Name, ' ', '); ---3
Update #temp Set Name=replace (Name, ' ', '); ---4

-the results are valid.

--Practical Project Application

Update waterquality Set Fecalcoliform=replace (Fecalcoliform, ","); ---1
Update waterquality Set Fecalcoliform=replace (Fecalcoliform, ","); ---2
Update waterquality Set Fecalcoliform=replace (Fecalcoliform, ","); ---3
Update waterquality Set Fecalcoliform=replace (Fecalcoliform, ","); ---4

You may have a question why do the same things repeat??

A: "This thing looks the same, and it's actually different."

You need to copy the column completely, and then select All to see if the bump status is empty after them.

Then you can copy and modify the blank spaces that have not been modified successfully.

For example, copy out into single quotes to observe ' 2.0x10 ', then copy out its unique ', and then perform a modification.

Before modification:

After modification:

Third, failure experience:

1.trim method

Select LTrim (' 3.3x10 ')--remove the left space
Select RTrim (' 3.3x10 ')--remove the space on the right
Select LTrim (RTrim (' 3.3x10 '))--Remove the leading and trailing spaces

The results are valid.

But the real data is this ' 3.3x10 '

Select LTrim (RTrim (' 3.3x10 '))--Remove the leading and trailing spaces

The result is invalid.

Articles that have been referenced:

Https://zhidao.baidu.com/question/183968041.html

Https://www.cnblogs.com/TurboWay/p/5924445.html

SQL minus Spaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.