I am writing a process that bulk inserts data from a flat file into a new table. To cut a long story short I can't use SSIS/DTS so am writing in code.
I have set it up so that all the source files are in a table and have written dynamic sql to pull out the file details, path, name and table to populate. Then using a While Loop it goes through each file and imports the data into the previously stated table. This is working fine, however I now want to add in code to move onto the next file if a file is missing. What is the best method of doing this?
I originally wrote it as a If Break else continue script, but the second one I used when there are no files left to import fails as it would appear that you can only use this syntax once inside a while loop. I then considered a Raiserror but can't see how I can use that and get it to continue onto the next file.
I'm slightly perplexed any ideas greatfully received.
If a file is missing, how is it in the collection of files to loop around?
answered May 20 '11 at 02:09 AM
Kev Riley ♦♦