Replacing database table rows with incremental values

Spread the love

As the General Data Protection Regulation (GDPR) is in effect tomorrow, I am getting rid of all personal data from our development databases. However for some databases just deleting users in not an option, so I am replacing all the data with dummy values. I wrote a little script which updates all table rows in the Users Table in a Microsoft SQL Server database with dummy data.

--Declare and initialize Incremental Variable
DECLARE @IncrementValue int
SET @IncrementValue = 0 

--Updates all table rows
UPDATE AspNetUsers 
SET Email = CONCAT('user',@IncrementValue, ''),
Username = CONCAT('user',@IncrementValue, ''),  
Name = CONCAT('User ',@IncrementValue),@IncrementValue=@IncrementValue+1

Running this script produces the following result:

Mission accomplished! Dummy data in a few seconds.

Leave a Reply

Your email address will not be published. Required fields are marked *