BULK INSERT Operating System Error Code 32
I am making use of BULK INSERT within a stored procedure and I get this error:
Cannot bulk load because the file "D:vanAS_TEST_vanRunGroupervan_DB.csv" could not be opened. Operating system error code 32(error not found).
Notice the path has no slashes although it does when I use the BULK INSERT. In addition, I get a code 32 and although the error description was not found. When I looked it up in a few forums (nothing definitive) it seems that the error code relates to:
The process cannot access the file because it is being used by another process.
Can anyone confirm this?
Also, why is the file path missing slashes when the bulk insert command was passed a file path wi开发者_如何学编程th slashes?
Thanks all for any help
Update
This is how I call the stored procedure:
exec data_Import ''D:\van\AS_TEST_van\Run\Grouper\van_DB.csv'', APCE_1011_Grouper_Out_FCE
This is how I run the bulk insert within the stored procedure:
exec('BULK INSERT dbo.' + @Table + ' FROM ''' + @PathFileName + ''' WITH (FIELDTERMINATOR ='','', FIRSTROW = 2, ROWTERMINATOR =''\n'')')
Please note, I have edited file paths.
The reason I got this error code is that at an unfortunate split second of time another program accessed this file and had a lock on it!
I hope this helps someone else in the future.
Try escaping the "\" with double backslaches "\". Th way iread it the \ is ignored because it does not result in a control character with the following character. Backslash is a special character in SQL.
Please make sure files you're trying to import are located on the server. Or modify path to read them from network share, ie. \\PC1\\imports\....
Please make sure your target folder is not "read-only" checked in the property.
精彩评论