To mask an email ID in SQL Server, one can use the STUFF function to remove some characters, put
* on the result set, and put back some characters at the end.
Example Query:
SELECT
Email,
STUFF(Email, CHARINDEX('@', Email) - 3, 3, '***') AS MaskedEmail
FROM
YourTable;
Explanation:
CHARINDEX('@', Email): Finds the position of the
@ symbol in the email.
STUFF: Replaces the characters starting 3 characters before the
@ with ***.
Hope it helps!!
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To mask an email ID in SQL Server, one can use the
STUFFfunction to remove some characters, put*on the result set, and put back some characters at the end.Example Query:
Explanation:
CHARINDEX('@', Email): Finds the position of the@symbol in the email.STUFF: Replaces the characters starting 3 characters before the@with***.Hope it helps!!