• Chances are the issue has nothing to do with osql but I am compelled to say it anyway, switch to using sqlcmd.exe, osql.exe has been a deprecated feature since SQL 2005 🙂

    pageiolatch_ex means a query in the script needs data from disk. You said the scripts ran in seconds when run 1 by 1. Was that is an SSMS query window? And was that against the same database with the same amount of data on a server with the same amount of activity?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato