for loop

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
 
F

foxidrive

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top