How would I go about creating a query to replace a social security number from the middle of a text block?
The table is like this:
column1 column2
11 text SSN more text
SSNs are not all formatted the same either, some are like this xxx-xx-xxxx and some are just a number string xxxxxxxx.
If you are wanting for example to redact SSN#’s from your table, you can make use of the
PATINDEXfunction to find SSN#’s and theREPLACEcommand to convert them to something that hides the number. Here is an example (note that this code assumes there will only be one SSN# in a value at once. If there could be multiple different SSN#’s, only the first one will be found):Sample input data:
Sample Output: