I was just about to start a script to do this but kh99 beat me to it.
One thing I would suggest is place that entire script inside a conditional so it runs for the admin only and then it can be a plugin in showthread start
PHP Code:
if($vbulletin->userinfo['userid'] == 1)
{
SCRIPT
}
I do this whenever I have to do any DB changes. It saves having to create a new file with all the standard requires.