for loop

  • Thread starter Thread starter pelegk1
  • Start date Start date
P

pelegk1

i am using a for loop to upload files to sql server :

for %%f in ( %BULK_UPLOAD_BASE%\Temp\*.txt) do bcp
[report].dbo.TargetTable in %%f -Sdesymesrv.kt.agh.edu.pl
\DESYME_KT_SQL -Usa -h "TABLOCK" -e %BULK_UPLOAD_BASE%\Error\Err.txt -
o %BULK_UPLOAD_BASE%\Logs\Output.txt -Ppassword -C RAW -f
%BULK_UPLOAD_BASE%\format_without_RawData.fmt

can i somehow in the for loop for example to take only 10 files?

thnaks in advance
peleg
 
i am using a for loop to upload files to sql server :

for %%f in ( %BULK_UPLOAD_BASE%\Temp\*.txt) do bcp
[report].dbo.TargetTable in %%f -Sdesymesrv.kt.agh.edu.pl
\DESYME_KT_SQL -Usa -h "TABLOCK" -e %BULK_UPLOAD_BASE%\Error\Err.txt -
o %BULK_UPLOAD_BASE%\Logs\Output.txt -Ppassword -C RAW -f
%BULK_UPLOAD_BASE%\format_without_RawData.fmt

can i somehow in the for loop for example to take only 10 files?

Using vanilla batch you can precede that loop with an earlier loop and echo
ten files (using 'set /a' as a counter) into a temp file. Then use

for /f "delims=" %%a in (file.tmp) do ... your code
 
Back
Top