problem with bulk insert

  • 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

  • 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

  • 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

  • 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

  • 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