The SQL Trim () function removes two spaces

Source: Internet
Author: User
Tags rtrim strfind

1.sql trim () function to remove two spaces
The SQL syntax does not directly remove the function of two spaces, but LTrim () removes the left space RTrim () to remove the right space.
Combined with the trim () function of SQL, select LTrim (RTrim (usrname))

Another way:

Replace (strsource, Strfind, Strreplaceas)

Strsource: source string, such as: Zhang San.
Strfind: The characters to be replaced, such as: spaces.
Strreplaceas: What characters to replace, such as: a string of length 0.

Select Replace (' Zhang San ', ' ', ')

2.DISTINCT Select multiple columns where one column cannot be duplicated and the other columns take the maximum value.
Goodname goodversion
Item 11.0
Item 12.0
Item Two 1.0
Item Two 2.0
If you want to
Item 12.0
Item Two 2.0
With select distinct goodname,goodversion from. No way.
When the distinct acts on two columns, it is the repetition of the two columns at the same time.
So it is handled in a special way.
Select Max (goodname), Max (goodversion) from T_good GROUP by Goodname
By grouping Goodname, you can guarantee that the goodname will not be duplicated.

3. Empty the Date field in SQL Server and empty it with backspace key, unable to save.
Update table1 set mydate=null;

The SQL Trim () function removes two 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.