我正在使用SQL Server 2008 R2。
如何更新字段如下:
""AUGUSTO NETO"" <augusto@uol.com>
""ANTONIO FAUSTINO"" <faustino@bol.com>
""ANDRE FORTINO"" <fortino@gmail.com>
""ADAUTO NETO"" <adauto@hotmail.com>
到
augusto@uol.com
faustino@bol.com
fortino@gmail.com
adauto@hotmail.com
我知道如何删除一些字符:
update myTable set [E-mail]=REPLACE([E-MAIL],'""','') WHERE [E-MAIL] LIKE '%@%'
update myTable set [E-mail]=REPLACE([E-MAIL],'<','') WHERE [E-MAIL] LIKE '%@%'
update myTable set [E-mail]=REPLACE([E-MAIL],'>','') WHERE [E-MAIL] LIKE '%@%'
有谁知道我该如何解决?
提前致谢。
答案 0 :(得分:0)
这应该这样做:
只需将YourColumn
替换为实际的列名,将YOURTABLE
替换为实际的表名
SELECT REPLACE(REPLACE(SUBSTRING(YourColumn, CHARINDEX('<', YourColumn), LEN(YourColumn)), '<', ''), '>', '')
FROM YOURTABLE;