A common SQL statement is used to delete instance programs with repeated characters in strings. For more information, see.
A common SQL statement is used to delete instance programs with repeated characters in strings. For more information, see.
Now, you need to filter the records with the same phone numbers and delete only one record.
| The Code is as follows: |
|
|
20051218125830_5988312367.vox
20051218125850_5988312367.vox
20051218135407_5932733345.vox
20051218175857_5923922228.vox
20051218180045_5923922228.vox
The remaining records after filtering are:
20051218125830_5988312367.vox
20051218135407_5932733345.vox
20051218175857_5923922228.vox |
Solution
Create a new table table_test to store the filtered records. Rename the table.
Z is the field
| The Code is as follows: |
|
| Create table table_test as (select min (z) z from c group by substr (z, 16 )) |
Another method
| The Code is as follows: |
|
|
--- Remove duplicate strings? Steal the island ?? Br/> create function StringRemove (@ str nvarchar (2000 ))
Returns varchar (2000)
As
Begin
Declare @ result nvarchar (2000), @ temp nvarchar (1000)
Set @ result =''
Set @ temp =''
While (charindex (',', @ str) <> 0)
Begin
Set @ temp = substring (@ str, 1, charindex (',', @ str ))
If (charindex (@ temp, @ result) <= 0)
Set @ result = @ result + @ temp
Set @ str = stuff (@ str, 1, charindex (',', @ str ),'')
End
Return @ result
End
GO
--('? T juwen ','? T ','? T juwen', '1', '23', '1 ')
--? Y?
Select dbo. StringRemove ('? T juwen ,? T ,? T juwen, 1, 23, 1 ') |