I will have daily 3 files coming into my C:
drive with timestamps in YYMMDDhhmm
format. for ex. TotalSale1611160037
means 2016-11-16 12:37 am
TotalSale1611160037
RegionSale1611160037
Statesale1611160037
I have scheduled a job in SQL Server Agent to load these 3 files into SQL Server 2014.
My requirement is that before starting the loading job, I need to check if the 3 files are present on the C:
drive. The job should run only if the 3 files are present on the C:
drive.
If any of these files are missing on the C:
drive, the load job should not run and send a database email showing which files are missing.
The first part of the files (TotalSale
,RegionSale
,Statesale
) will be same every day; only the timestamp (1611160037
) will change. After the load process I will move those files into another folder.
Please help me. I don't know how to check files exist using wild card characters in SQL Server.
Thank you for your time and help