but this always returns 0 becuase the last statment it run was the & so is there a way to get the return code of the sqler script rather than the return code of the background process.
The return code can only be reaped when the process finishes. Have a look at the wait command. (You will want to wait on that specific process; you get its process ID in $! when you have just started it.)
bash$ help wait
wait: wait [n]
Wait for the specified process and report its termination status. If
N is not given, all currently active child processes are waited for,
and the return code is zero. N may be a process ID or a job
specification; if a job spec is given, all processes in the job's
pipeline are waited for.