September 30, 2011 at 4:52 pm
I have the following code:
CREATE TABLE CSVTest
(ID INT,
FirstName VARCHAR(40),
LastName VARCHAR(40),
BirthDate SMALLDATETIME)
GO
BULK
INSERT CSVTest
FROM 'c\data\tempfile.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
)
GO
but i get an error when i try to use it.
the error is as follows:
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "c\data\tempfile.txt" could not be opened. Operating system error code 3(The system cannot find the path specified.).
i tried adding the name of the computer to the address hoping it will work but i get the following error:
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\\LTSR397941\c\data\tempfile.txt" could not be opened. Operating system error code 53(The network path was not found.).
we are using SQL server 2008 with windows authentication.
sql server resides on a remote server to which i have access.
can anyone tell me what is wrong with the situation.
thanks
Vijaya
September 30, 2011 at 9:55 pm
You are missing the full colon ":" in your path
FROM 'c\data\tempfile.txt'
Should be:
FROM 'c:\data\tempfile.txt'
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
October 4, 2011 at 3:22 pm
In addition to above... if you're not on the same sever as the script, you'd need to use the \\machine-name\share notation. For example, to make c:\Data\data.txt available to other servers, you'd start by sharing the c:\Data folder as "PublicData", and then you'd reference the file as \\machine-name\PublicData\data.txt
October 4, 2011 at 9:32 pm
Very correct Paul.
And in the case above, they can't find the file specified via the mapped UNC path because of the missing "$" (admin share, which of course should never be used)
Cannot bulk load because the file "\\LTSR397941\c\data\tempfile.txt" could not be opened
Shoulld be:
\\LTSR397941\c$\data\tempfile.txt
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
October 4, 2011 at 10:47 pm
The error itself is self explanatory, if your file is in the same machine and copy the files complete path and use it.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply