HI There, I need to anonymize some data but also need to keep the data integrity. the plan is remove the current data in the column and then add new data. the format is 2 letter followed by 7 digits but i am nto sure how to go about populating the column. Has anyone had this issue before and developed a quick script for it?
Here is a solution: This was borrowed from Aaron Bertrand and modified to include the 'AB' letters. Note that it will generate 2 million random numbers. You might have to adjust for your needs ;WITH x AS ( SELECT TOP (2000000) s1.[object_id] FROM sys.all_objects AS s1 CROSS JOIN sys.all_objects AS s2 ORDER BY s1.[object_id] ) SELECT r = ROW_NUMBER() OVER (ORDER BY [object_id]), n = 'AB' + CAST(1000000 + ROW_NUMBER() OVER (ORDER BY NEWID()) AS VARCHAR(25)) FROM x ORDER BY r; Reference: