Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
abhishek_kumar_rch
Starting Member
6 Posts |
Posted - 2014-11-29 : 03:30:23
|
Hi,There is email address in my datablse table column as usernameI have to select it from database in such a way so that first two letter and lasttwo letters only visible before @for example this email id (sontosh_kumar_rch@yahoo.com) should be selected in below format..sontosh_kumar_rch@yahoo.comsa...............ch@yahoo.com |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-29 : 11:37:52
|
1. use CHARINDEX to find the @ character2. use the result of 1 to split the email into two parts: name and domain3. For the name. take LEFT(name, 2) + replicate('.', len(name) -4) + right(name, 2)4. add @ and the domain name to the end of the new name |
|
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-12-01 : 09:21:39
|
[code]DECLARE @var varchar(max) = 'santosh_kumar_rch@yahoo.com'SELECT REPLACE(@var,SUBSTRING(@var,3,PATINDEX('%@%',@var)-5),'------')[/code]---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
|
|
|