0

I've been working on exporting a table to a file, and had problems with the bcp (bulk copy program) part of the procedure locking up. The code worked fine when I ran it as a script, but would generate locked processes when I wrapped it in a stored procedure.

John Hunter
  • 19
  • 1
  • 4

1 Answers1

0

I seem to have found the solution; COMMIT. Namely, I had to wrap the code which truncated and inserted into the table which bcp would be picking up the data from within a BEGIN TRANSACTION...COMMIT. Now the procedure works

I think it is to do with the command exec master.dbo.xp_cmdshell @bcp going outside of the SQL session to the OS. Am I correct, or is there a better explanation?

John Hunter
  • 19
  • 1
  • 4