2009-02-15
for-i-repeat
Update 2009-05-31: New version 1.1.
I just finished developing a small tool called for-i-repeat that can duplicate a text-fragment a number of times using a counter. The reason I needed this is for the following scenario: at work we have a machine that has 50 databases that all have the same schema, but different data. If I want to modify the schema of all 50 databases, I create a SQL script that applies the modifications to 1 database, put USE Database01 in front of it, and run it 50 times, each time modifying the USE-statement with the next database number. for-i-repeat allows me to convert this input:
USE Database{0:00}
ALTER TABLE ...
into this output:
USE Database01 ALTER TABLE ... USE Database02 ALTER TABLE ... USE Database03 ALTER TABLE ... ... USE Database50 ALTER TABLE ...
A real time-saver! To format the counter {0}, you can use the full range of .NET numeric formatting options, including hexadecimal formatting ({0:X}).
You can download for-i-repeat here.