Easiest is to use bulk insert.
Look at the link I gave you - it gets all the files in a directory and loops through them.
For each file it does a bulk inisert and moves the file to an arcghive directory.
Just take out the bits you need.
This gets a list of all files in the directory
select @cmd = 'dir /B ' + @FilePath + @FileNameMask
delete #Dir
insert #Dir exec master..xp_cmdshell @cmd
delete #Dir where s is null or s like '%not found%'
This loops though each file
while exists (select * from #Dir)
begin
select @FileName = min(s) from #Dir
select @File = @FilePath + @FileName
-- remove filename just imported
delete #Dir where s = @FileName
end
This bulk inserts the file
select @cmd = 'bulk insert'
select @cmd = @cmd + ' ##Import'
select @cmd = @cmd + ' from'
select @cmd = @cmd + ' ''' + replace(@File,'"','') + ''''
select @cmd = @cmd + ' with (FIELDTERMINATOR=''|'''
select @cmd = @cmd + ',ROWTERMINATOR = ''' + char(10) + ''')'
truncate table ##Import
-- import the data
exec (@cmd)
This archives the file
-- Archive the file
select @cmd = 'move ' + @FilePath + @FileName + ' ' + @ArchivePath + @FileName
exec master..xp_cmdshell @cmd
The proc MergeBCPData just moves the data to the production table.
======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.