Add 10 Years To All Dates in MySQL Database
===

I'm trying to setup a demo of some software for a client and need live reporting data to do so.  This is business software that will rely on information that would normally reside in an ERP type system where there are sales orders and purchase orders (and all the data to build those things).

I looked long and hard for a sample ERP database and the only thing I could come up with was [MySQL port of the MS AdventureWorks DB][1].  This is great and has a lot of data I can use to sample.

The problem is, all the dates on the orders are from 2001-2004.

What I'd like to do is write a simple MySQL script that will loop through every datetime field in the entire AdventureWorks DB and add 10 years to it.  This will make the date range (2011-2014), which is much more reasonable.

I found [this post][2] that had a very similar script I thought I could borrow from, but for some reason I can't seem to port it over to MySQL.

I've boiled it down to this little piece of code.  For some reason, my MySQL will not run the WHILE loop - and I am clueless why.

    USE adventureworks;
        
    CREATE TEMPORARY TABLE ColumnList 
           (
          TableName NVARCHAR (100),
          columnName NVARCHAR (100)
           );
    
    
    INSERT INTO ColumnList
            select t.table_name,c.column_name
            from information_schema.tables t inner join information_schema.columns c on t.table_name=c.table_name
            where c.column_type = 'datetime';
    
    SET @Counter = 1;
    SET @TotalCount = (SELECT COUNT(*) FROM ColumnList C);
    
    WHILE @Counter <= @TotalCount DO
        BEGIN
          -- do stuff here
        END
    END WHILE;

Error that comes out:

    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @Counter <= @TotalCount DO
    BEGIN
      -- do stuff here
    END
    END WHILE' at line 1

Any help would be appreciated.

  [1]: http://sourceforge.net/projects/awmysql/
  [2]: http://www.mikereigler.com/archive/2010/09/update-all-datetime-columns-in-a-database-with-new-dates/