Check out my blog post on this topic.
I had the best luck with SSIS (Attempt 4):
For your case, if you have to stay in T-SQL, see attempt 3. Items 7-10 detail the issue you are facing and how to work around it.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato