I had a list of Email Id's in a column as shown like chota.bheem@gmail.com. All email ID's had dots in between first name and last name. I needed to replace the dots by underscore that only existed between first name and last name. Not the dot in "gmail.com". When I used replace function, both dots would get replaced with underscore. So STUFF function helped me as shown below.
select 'chota.bheem@gmail.com',STUFF('chota.bheem@gmail.com',CHARINDEX('.','chota.bheem@gmail.com'),1,'_')
i.e.
select [your column],STUFF([your column],CHARINDEX('.',[your column]),1,'_')
No comments:
Post a Comment