本文介绍了如何在特定字符之前替换字符串的子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表格电子邮件:
值:
josh@yahoo carmine32@hotmail zehmaneh@yahoo我想用 test 替换 @ 之前的字符串.
I want to replace the string before @ with test.
结果:
test@yahoo test@hotmail test@yahoo如何使用子串并根据字符串中的字符进行替换?
How do I use substringing and replace based on a character in the string?
推荐答案你甚至不需要使用substring或replace,你可以使用这个:>
You don't even need to use substring or replace, you can use this:
SELECT 'test' + RIGHT(email, charindex('@', REVERSE(email))) FROM YourTable你可以用这个来测试一下:
You can test it out with this:
DECLARE @email nvarchar(50) SET @email = 'carmine32@hotmail' PRINT 'test' + RIGHT(@email, charindex('@', REVERSE(@email)))更多推荐
如何在特定字符之前替换字符串的子字符串?
发布评论