• I did something like this before. Just wanted to note how I did it as it can eliminate the use of sed grep and find (since you already are enabling xp_cmdshell). By importing the files directly using OS built in dir command, you can then find your deltas by importing again and using join to find out what has changed.

    insert files

    exec master..xp_cmdshell 'dir /S/b d:\temp\*.dat'

    delete files where filepath is null

    --then later, load up and compare again

    insert #files

    exec master..xp_cmdshell 'dir /S/b d:\temp\*.dat'

    delete #files where filepath is null

    --insert new

    insert files

    select fnew.filepath from #files fnew left outer join files fold on fnew.filepath = fold.filepath

    where fold.filepath is null

    --delete old

    delete files where filepath in(

    select fold.filepath from #files fnew right outer join files fold on fnew.filepath = fold.filepath

    where fnew.filepath is null)