• I agree with the advice to use something other than a direct call inside the transaction. Write the data you need to export to a table and then have an external process do the actual export. Service Broker would work. A plain-old "work table" could work too.

    As an aside, osql.exe has been deprecated since SQL 2005 was released. sqlcmd.exe is the replacement for it. Further to that osql is not really the right tool for exporting data. If you want a command line tool use bcp.exe but SSIS is usually my preference for this type of work.

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