Randomizing the Day Inside a Month Using T-SQL


I recently ran across an interesting situation in our development databases. We have begun to protect various PII information in our systems by running scripts in the development databases when we restore a production backup. We do this as we have had executives express concern about losing data that exists on developer laptops and other systems.

During one of our development sprints, we realized that we have a process that totals up birthdays in a month for some award system. Since we were randomizing dates of these events, the totals for events didn’t match any longer. As a result, we