I set to write about why you should be using the dbms's power or resources instead of the client's,mainly because of query optimization,execution plan caching,parallel query execution,set based operations instead of procedural row by row,etc, but then I've noticed the OP's remark Re^2: A database table size issue,which acts as straightforward reply to your
question :
Thanks for the suggestion. The script was really slow when I processed the table row by row. I took your advice and rewrote the SQL to let the DB to handle part of the processing. The script now runs much faster than before
So I have no futher comments