表电子邮件
:
值(value)观:
josh@yahoo.com
carmine32@hotmail.com
zehmaneh@yahoo.com
我想用test
替换@
之前的字符串。
结果:
test@yahoo.com
test@hotmail.com
test@yahoo.com
如何根据字符串中的字符使用子字符串和替换?
最佳答案
你甚至不需要使用substring
或replace
,你可以使用这个:
SELECT 'test' + RIGHT(email, charindex('@', REVERSE(email)))
FROM YourTable
你可以用这个来测试它:
DECLARE @email nvarchar(50)
SET @email = 'carmine32@hotmail.com'
PRINT 'test' + RIGHT(@email, charindex('@', REVERSE(@email)))
关于sql - 如何替换字符串中特定字符之前的子字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12371701/