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