December 21, 2009 at 1:36 am
Not sure if anyone else has seen this before, but I'm at a loss. I'm exporting records from a global temp table using bcp and this works fine. This is being done in a stored procedure using xp_cmdshell to call bcp to create the file, and then the file is also emailed.
The problem is that when I try to overwrite the file using bcp it fails. And when I try to just manually delete it, I get the error message "The actionan't be completed because the file is open in SQL Server Close the file and try again"
The bcp command I'm using is:
bcp "select * from tempdb..##Sub_Error_Temp" queryout "J:\SubLoad_Errors.csv" -c -t, -U xxxx -P xxxx -S SERVERNAME\INSTANCE
Has anyone else seen this before?
December 21, 2009 at 5:37 pm
I use BCP but usually do not use a global temp. I am curious when you dispose of the global ##temp. When you create the .txt it should not have anything to do with the #table. I would think it is something in the process that is locking it like a process running against which will not release a lock.
December 21, 2009 at 5:55 pm
BCP won't hold a table open like that. Something else has a grip on the table.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply