Wednesday, March 7, 2012

server to Text Files: is possible to detect changes made to those files? (SQL Server 2005

Hi gurus,

I've created a linked server (and set up the corresponding schema.ini file) in order to perform bulk-inserts from some CSV text files into SQL tables (from my standpoint the text files are just for reading purposes). The linked server works fine (I can select the data in the files without a problem).

Now the question: is possible to automatically detect when one or more of those files change in order to start the import process automatically? Something like having a trigger created on the CSV files Or there's no easy way to do that so I have, to say something, to create a Job that periodically checks if the files have changed programatically (say, recording each file's timestamp everytime is imported and comparing the recorded value with the current one, or whatever)?

Thanks a lot in advance!

I think it is not that kind of trigger... so for detecting changes I have some ideeas :

1.Probably there is something in WMI (see ) that let you detect modified data of your file; then compare it with a witness data that reside in SQL and import the file if there is a difference

2.Save the csv files with a name that include data ( 09_04_2007_20_23_12.csv) then in a SSIS package verify all that files ( with "for each loop container control flow item" vis-a-vis a witness data of last import and the import with data flow task.

The checking of new files should be made periodically in a job.

No comments:

Post a Comment