0

So here what I wanted:

Original value in a SQL server table with column comments:

Hyderabad 12-11-1989 " 123% "

Desired masked value

xxxxxxxxx xx-xx-xxxx " xxx% "

How can I get it in SQL server .. any function? Or update query ?

  • https://stackoverflow.com/questions/21378193/regex-pattern-inside-sql-replace-function – Jaybird Dec 22 '18 at 16:34
  • Possible duplicate of [Regex pattern inside SQL Replace function?](https://stackoverflow.com/questions/21378193/regex-pattern-inside-sql-replace-function) – The Impaler Dec 22 '18 at 18:40
  • If you are trying to permanently replace them in the original table, see above. If you are trying to mask the value returned, you'll want to create a view that uses the Regex replace in the example above as a calculated column and have queries point to the view rather than the original table. – user681574 Dec 22 '18 at 19:45
  • What version of SQL Server? – Martin Smith Dec 22 '18 at 23:06
  • SQL Server -2016 – akhilesh reddy Dec 24 '18 at 14:56
  • i tried below but I wanted to leave spaces and other punctuations to be as is ..ONLY change a-z,A-Z 0-9 SELECT REPLICATE('x', LEN(address)) from customers select TRANSLATE(address, '[^a-z0-9]', 'x') from customers – akhilesh reddy Dec 24 '18 at 15:09
  • SELECT REPLICATE('x', LEN(address)) from customers select TRANSLATE(address, '[^a-z0-9]', 'x') from customers – akhilesh reddy Dec 24 '18 at 15:38

0 Answers0