问题描述
我在从文本文件读取数据到ms sql时遇到问题。我在c:\中创建了一个名为data.txt的文本文件,但是由于某些原因,ms sql server无法找到该文件。我收到错误无法批量加载。文件 c:\data.txt不存在。有任何想法吗?
I'm having a problem reading data from a text file into ms sql. I created a text file in my c:\ called data.txt, but for some reason ms sql server cannot find the file. I get the error "Cannot bulk load. The file "c:\data.txt" does not exist." Any ideas?
数据文件(是的,我知道数据看起来很烂,但是在现实世界中,多数民众赞成它是如何从客户那里获得的):
The data file (yes I know the data looks crappy, but in the real world thats how it comes from clients):
01-04 10.338,18 0,00 597.877,06- 5 0,7500 62,278-
06-04 91.773,00 9.949,83 679.700,23- 1 0,7500 14,160-
07-04 60.648,40 149.239,36 591.109,27- 1 0,7500 12,314-
08-04 220.173,70 213.804,37 597.478,60- 1 0,7500 12,447-
09-04 986.071,39 0,00 1.583.549,99- 3 0,7500 98,971-
12-04 836.049,00 1.325.234,79 1.094.364,20- 1 0,7500 22,799-
13-04 38.000,00 503.010,49 629.353,71- 1 0,7500 13,111-
14-04 286.400,00 840.126,50 75.627,21- 1 0,7500 1,575-
The Sql:
CREATE TABLE #temp
(
vchCol1 VARCHAR (50),
vchCol2 VARCHAR (50),
vchCol3 VARCHAR (50),
vchCol4 VARCHAR (50),
vchCol5 VARCHAR (50),
vchCol6 VARCHAR (50),
vchCol7 VARCHAR (50)
)
BULK insert #temp
FROM 'c:\data.txt'
WITH
(
FIELDTERMINATOR = ' ',
ROWTERMINATOR = '\n'
)
select * from #temp
drop table #temp
推荐答案
它在服务器上运行,因此它在服务器的 C:
驱动器上寻找 C:\data.txt
。
That's run on the server, so its looking for C:\data.txt
on the server's C:
drive.
还请确保您使用的登录对C:具有读取权限。
Also ensure the logon your using has read permissions on C:.
这篇关于无法批量加载。文件“ c:\data.txt”不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!