Link to home
Start Free TrialLog in
Avatar of fool5683
fool5683Flag for United States of America

asked on

Importing data from a flat file into SQL Server DB using BCP utility

I am attempting to import data from a flat file into SQL Server DB using BCP utility. they both the file is on the same machine as the DB here is:

BCP WrongWrench.dbo.Art IN "D:\My Documents\filelib\Information 410\ Data.txt" -S LAPTOP\ITD410 -U Gregory -P -t "," -C

and I am getting:

Error = [Microsoft][ODBC SQL Server Driver] Unable to open BCP host data-file

Please advise on what could be the problem
Avatar of Jeeva Subburaj
Jeeva Subburaj
Flag of United States of America image

hey , i refer the net and i got this..

Sounds like the account you're logged in to the machine where you're running
the bcp command doesn't have access to the network drive you're trying to
use.  Is LAPTOP\ITD410... a valid UNC path?  Can you do a dir on it from
the command prompt?

OR,
instead of giving Server Name , Map the Server Into Some Drive and Put it Drive Letter there and try..

Hope this helps u




U can also m Use BULK INSERT instead of using that BCP utility..

Example
======
BULK INSERT Northwind.dbo.[Order Details]
    FROM 'f:\orders\lineitem.tbl'
    WITH
        (
            FIELDTERMINATOR = '|',
            ROWTERMINATOR = '|\n'
        )
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
make sure "Data.txt" is not in use\opened preor Bulk insert
try dts this file in database - makle sure the file is here:

BTW:
DTS is not bad solution for you....