是的,我有21000条记录,电子邮件地址末尾有数字(。+ 15位长号,例如:xyz@gmail.com.201211200200027)
现在,我能想到的最佳解决方案是:
Update TABLE
set EmailAddress = (
select substring (EmailAddress, 1, (len(EmailAddress) - 16))
from TABLE)
Where ISNUMERIC(RIGHT(Emailaddress, 15)) = 1
上面的代码不起作用(我不是T-SQL专家,请原谅我,如果这段代码看起来很蠢)
如果我告诉该代码是特定的电子邮件地址,那么它是有效的。像这样:
Update TABLE
set EmailAddress = (
select substring (EmailAddress, 1, (len(EmailAddress) - 16))
from TABLE)
Where ISNUMERIC(RIGHT(Emailaddress, 15)) = 1
and Emailaddress is 'xyz@gmail.com.201211200200027'
那么,如何更新这些电子邮件地址并删除最后16个字符?
答案 0 :(得分:0)
试试这个;
UPDATE yourTable
SET EmailAddress = LEFT(EmailAddress, LEN(EmailAddress) - 16 )
WHERE PATINDEX('%[^0-9]%', RIGHT(EmailAddress, 15)) = 0 AND LEN(EmailAddress) > 16