Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 bulk upload files to DB

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2007-06-19 : 04:09:11
i am using this code to upload file to a TempTable in the SQL SERVER :
"for %%f in ( F:\Temp\*.txt) do bcp ....."
the thing is that this code load all the file that in a given folder to the table.
is it possible to some how (using a switch or anything else) that only 10 files each time will be uploaded?
thnaks in advance
peleg


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

Kristen
Test

22859 Posts

Posted - 2007-06-19 : 07:59:30
for %%f in ( F:\Temp\*.txt) do CALL :MyAction ....."

and have MyAction increment an Environemtn Variable, and bail out once it gets to 10 ?

Move all-BUT 10 files OUT of F:\Temp before you start?

Kristen
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2007-06-19 : 08:13:02
the most simple solution of course is to move every time 10 files to another folder and load from there
i thought maybe i can do it as part as the for command

how do i implement your code to the end so it will work?


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-19 : 08:18:35
why not use BULK INSERT ? you can control the files to import from T-SQL.


KH

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-06-19 : 08:24:58
Something like this perhaps?

SET MyCount=0
for %%f in ( F:\Temp\*.txt) do CALL :MyAction %%f"
GOTO NextStep

:MyAction
MOVE %1 F:\TEMP\WorkFiles
GOTO END

:NextStep
... Process files in F:\TEMP\WorkFiles ...
GOTO END

:END

Kristen
Go to Top of Page
   

- Advertisement -