# Database Discussions > MS SQL Server 7/MS SQL Server 2000 >  BCP Problem

## Srinivasan

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## Rich

Try specifying the full path to both the emp.txt and the emp.fmt files

Example:  &#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


------------
Srinivasan at 8/27/00 4:56:33 PM

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## Srinivasan

Hi Rich, 
Tks for ur advice. Even I tried as per ur advice still I am getting the same error mesg. The following is the command I have given,

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1	SQLCHAR	0	10	&#34;,&#34;	1	EMPLOYEEID
2	SQLCHAR	0	30	&#34;,&#34;	3	LastName
3	SQLCHAR	0	30	&#34;
,&#34;	2	FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid  firstname                      lastname                       
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan






------------
Rich at 8/27/00 9:47:48 PM

Try specifying the full path to both the emp.txt and the emp.fmt files

Example:  &#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


------------
Srinivasan at 8/27/00 4:56:33 PM

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## Dan

If you have the files open in another editor, close them when running the BCP.

Also I&#39;ve seen SQL Server behave fine if the files are on the server and BCP is executed on the same server, but put everything on a client and run it from there and BCP reports the same errors you&#39;re seeing. If you can run it from the server only it might help you figure out where the problem lies.

Dan

------------
Srinivasan at 8/28/00 10:31:57 AM

Hi Rich, 
Tks for ur advice. Even I tried as per ur advice still I am getting the same error mesg. The following is the command I have given,

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1	SQLCHAR	0	10	&#34;,&#34;	1	EMPLOYEEID
2	SQLCHAR	0	30	&#34;,&#34;	3	LastName
3	SQLCHAR	0	30	&#34;
,&#34;	2	FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid  firstname                      lastname                       
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan






------------
Rich at 8/27/00 9:47:48 PM

Try specifying the full path to both the emp.txt and the emp.fmt files

Example:  &#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


------------
Srinivasan at 8/27/00 4:56:33 PM

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## Srinivasan

Hi Dan,

Tks for ur suggestion. I have closed all the files which were used in the &#39;BCP-in&#39;. As per u said, I first tried from the client machine only at that time I got this error first. Then only I tried from the server. I don&#39;t know still I am getting the same error.

Can anyone please help me.

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1 SQLCHAR 0 10 &#34;,&#34; 1 EMPLOYEEID
2 SQLCHAR 0 30 &#34;,&#34; 3 LastName
3 SQLCHAR 0 30 &#34;
,&#34; 2 FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid firstname lastname 
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan




------------
Dan at 8/29/00 8:10:27 AM

If you have the files open in another editor, close them when running the BCP.

Also I&#39;ve seen SQL Server behave fine if the files are on the server and BCP is executed on the same server, but put everything on a client and run it from there and BCP reports the same errors you&#39;re seeing. If you can run it from the server only it might help you figure out where the problem lies.

Dan

------------
Srinivasan at 8/28/00 10:31:57 AM

Hi Rich, 
Tks for ur advice. Even I tried as per ur advice still I am getting the same error mesg. The following is the command I have given,

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1	SQLCHAR	0	10	&#34;,&#34;	1	EMPLOYEEID
2	SQLCHAR	0	30	&#34;,&#34;	3	LastName
3	SQLCHAR	0	30	&#34;
,&#34;	2	FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid  firstname                      lastname                       
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan






------------
Rich at 8/27/00 9:47:48 PM

Try specifying the full path to both the emp.txt and the emp.fmt files

Example:  &#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


------------
Srinivasan at 8/27/00 4:56:33 PM

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## AVW

check permissions where the data files are located.


------------
Srinivasan at 8/29/00 2:01:20 PM

Hi Dan,

Tks for ur suggestion. I have closed all the files which were used in the &#39;BCP-in&#39;. As per u said, I first tried from the client machine only at that time I got this error first. Then only I tried from the server. I don&#39;t know still I am getting the same error.

Can anyone please help me.

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1 SQLCHAR 0 10 &#34;,&#34; 1 EMPLOYEEID
2 SQLCHAR 0 30 &#34;,&#34; 3 LastName
3 SQLCHAR 0 30 &#34;
,&#34; 2 FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid firstname lastname 
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan




------------
Dan at 8/29/00 8:10:27 AM

If you have the files open in another editor, close them when running the BCP.

Also I&#39;ve seen SQL Server behave fine if the files are on the server and BCP is executed on the same server, but put everything on a client and run it from there and BCP reports the same errors you&#39;re seeing. If you can run it from the server only it might help you figure out where the problem lies.

Dan

------------
Srinivasan at 8/28/00 10:31:57 AM

Hi Rich, 
Tks for ur advice. Even I tried as per ur advice still I am getting the same error mesg. The following is the command I have given,

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


c:emp.txt:-
**********
1,&#34;Press&#34;,&#34;Jon&#34;
2,&#34;Noel&#34;,&#34;David&#34;
3,&#34;Graziano&#34;,&#34;William&#34;
4,&#34;Miller&#34;,&#34;Chris&#34;

c:emp.fmt:-
**********
7.0
3
1	SQLCHAR	0	10	&#34;,&#34;	1	EMPLOYEEID
2	SQLCHAR	0	30	&#34;,&#34;	3	LastName
3	SQLCHAR	0	30	&#34;
,&#34;	2	FIRSTNAME

&#39;emp&#39; Table structure in &#39;hrm&#39; Database
***************************************
employeeid  firstname                      lastname                       
----------- ------------------------------ ------------------------------ 

Still the Same Error Mesg.
****************************
&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please help me.

tks in advance,
Srinivasan






------------
Rich at 8/27/00 9:47:48 PM

Try specifying the full path to both the emp.txt and the emp.fmt files

Example:  &#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;


------------
Srinivasan at 8/27/00 4:56:33 PM

Hi Everybody,

I have a problem in importing a text file into the &#39;SQL Server Database&#39; through &#39;BCP in&#39; command.

The problem is, I have a data file called &#34;emp.txt&#34;(fields separated by comma,which has to be imported into a table), a format file called &#34;emp.fmt&#34; (where version,no_of_columns,data_type,etc been declared here) and the table &#34;emp&#34; already been created in the respective database. I have applied the following command in the dos prompt,

&#34;bcp hrm..emp in emp.txt -f emp.fmt -Usa -Psa -Ssqlcap&#34;

After applying the above command I am getting the following error,

&#34;
SQLState = S1000, NativeError = 0,
Error = [MS][ODBC SQL Server Driver] Unable to open BCP host data-file
&#34;

Can anyone please explain me to solve this problem.

tks in advance,
Srinivasan

----------


## Dan

I think your problem is the -i
It&#39;s not required.

There is no datafile specified in your statement below.

&#34;bcp hrm..emp in -ic:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;

It should look like

&#34;bcp hrm..emp in c:emp.txt -fc:emp.fmt -Usa -Psa -Ssqlcap&#34;

Dan

----------

