2

I have the following bulk insert script

$sql="BULK
                INSERT nibble
                FROM 'd:\nibble.csv'
                WITH
                (
                FIELDTERMINATOR = ',',
                ROWTERMINATOR = '\n',
                FIRSTROW=2
                )

                ";
mssql_query($sql);

Msg 4860, Level 16, State 1, Line 1 Cannot bulk load. The file "d:ibble.csv" does not exist.

but when i execute from sql below server management studio it works .. what is the issue

BULK
                INSERT nibble
                FROM 'd:\nibble.csv'
                WITH
                (
                FIELDTERMINATOR = ',',
                ROWTERMINATOR = '\n',
                FIRSTROW=2
                )

1 Answer 1

1

You need to escape the backslash with another backslash. From d:\nibble.csv to d:\\nibble.csv

Do this way..

<?php
$sql="BULK
                INSERT nibble
                FROM 'd:\\nibble.csv'
                WITH
                (
                FIELDTERMINATOR = ',',
                ROWTERMINATOR = '\n',
                FIRSTROW=2
                )

                ";
mssql_query($sql);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.