# Miscellaneous > General Database Discussions >  using bcp in a bacth file   exe bcp.bat

## Ali Alhussein

hi, I have this code to run bcp from within sql window, it works fine
Exec master..xp_cmdshell &#34;bcp sdnetpro..nbtorder11 in c:dataNbtorder11.txt  /c  /t 	 /Sntrsnlva104 /Usa /Psdreport&#34;

when I put put the same code in a batch file named bcp.bat. then double click it it does not work..can anyone modfiy my code so I can run the bcp process it from within the batch file

here what I tried in a batch file 


@ECHO OFF
REM Add Start time to the LOG
ECHO.|TIME *************time *******************
::Copy new records into nbtorder11
echo BCP: c :Big Grin: ata
btorder11	
BCP SDNETPRO.dbo.nbtorder11 in c :Big Grin: ata
btorder11.txt -S NTRSNLVA104 -U sa -P SDREPORT -c -t -r, &#34;
&#34;

----------


## Kenneth Wilhelmsson

What kind of error do you get?

Looks in your example that yiu have mixed up the switches in the .bat example.
You have a comma just after the -r rowdelimiter.
Could that be it or is it just a typo?

/Kenneth

------------
Ali Alhussein at 5/19/99 3:18:44 PM

hi, I have this code to run bcp from within sql window, it works fine
Exec master..xp_cmdshell &#34;bcp sdnetpro..nbtorder11 in c:dataNbtorder11.txt  /c  /t 	 /Sntrsnlva104 /Usa /Psdreport&#34;

when I put put the same code in a batch file named bcp.bat. then double click it it does not work..can anyone modfiy my code so I can run the bcp process it from within the batch file

here what I tried in a batch file 


@ECHO OFF
REM Add Start time to the LOG
ECHO.|TIME *************time *******************
::Copy new records into nbtorder11
echo BCP: c :Big Grin: ata
btorder11	
BCP SDNETPRO.dbo.nbtorder11 in c :Big Grin: ata
btorder11.txt -S NTRSNLVA104 -U sa -P SDREPORT -c -t -r, &#34;
&#34;

----------


## Jim Jang

Here is the revised code.

BCP SDNETPRO.dbo.nbtorder11 in c :Big Grin: ata
btorder11.txt /c /t, /r 
 -SNTRSNLVA104 -Usa -PSDREPORT 

------------
Kenneth Wilhelmsson at 5/20/99 7:09:36 AM

What kind of error do you get?

Looks in your example that yiu have mixed up the switches in the .bat example.
You have a comma just after the -r rowdelimiter.
Could that be it or is it just a typo?

/Kenneth

------------
Ali Alhussein at 5/19/99 3:18:44 PM

hi, I have this code to run bcp from within sql window, it works fine
Exec master..xp_cmdshell &#34;bcp sdnetpro..nbtorder11 in c:dataNbtorder11.txt  /c  /t 	 /Sntrsnlva104 /Usa /Psdreport&#34;

when I put put the same code in a batch file named bcp.bat. then double click it it does not work..can anyone modfiy my code so I can run the bcp process it from within the batch file

here what I tried in a batch file 


@ECHO OFF
REM Add Start time to the LOG
ECHO.|TIME *************time *******************
::Copy new records into nbtorder11
echo BCP: c :Big Grin: ata
btorder11	
BCP SDNETPRO.dbo.nbtorder11 in c :Big Grin: ata
btorder11.txt -S NTRSNLVA104 -U sa -P SDREPORT -c -t -r, &#34;
&#34;

----------

