December 4, 2008 at 4:20 pm
Hi Frenz
I am trying to import a large csv file to my SQL server the file is of size 2 gb.
I am using the bulk inser query i nsql but it keeps giving the error " file does not exist"
I have checked the path of the file many times and its fine.
I ran a sample query to check if it works with the smaller files but it failed:
Here is the syntax:
USE testDB
GO
CREATE TABLE CSVTest
(ID INT,
FirstName VARCHAR(40),
LastName VARCHAR(40),
BirthDate SMALLDATETIME)
GO
BULK
INSERT CSVTest
FROM 'P:\Business Services\test.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
)
GO
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "P:\Business Services\test.txt" could not be opened. Operating system error code 3(error not found).
Can anyone please help??
Thanks
December 4, 2008 at 4:38 pm
Try using an UNC for the file instead of what appears to be a mapped drive:
BULK INSERT CSVTest
FROM '\\servername\sharename\Business Services\test.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
)
GO
December 4, 2008 at 5:28 pm
The UNC is a good idea. I have often seen people trying to BCP files from drives on their personal PC rather than the server. (I've never gotten in a hurry and done this myself, oh no, not me, nope.) When you use BCP it runs on the server and can only see what the server sees. Surely the same applies to bulk inserts.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply