String strTableName;
String strSql;
declare mycursor cursor for select name from db1.dbo.sysobjects where xtype = 'U';
open mycursor;
fetch mycursor into :strTableName;
do while sqlca.sqlcode = 0
strSql = 'select * into db2.dbo.'+strTableName+' from db1.dbo.'+strTableName;
execute immediate :strSql using sqlca;
fetch mycursor into :strTableName;
loop;
close mycursor;