December 10, 2008 at 12:48 pm
After the datawarehouse load is complete, a txt file is placed on some server. I need to execute the job as soon as I find the txt file. I was told I need to do this in a batch script. I would appreciate if anyone has this coded.
December 10, 2008 at 1:03 pm
It's most likely you have to call the batch commands to check for the text file regularly, then if found, run the job
http://www.kodyaz.com/articles/read-text-file-using-xp_cmdshell.aspx
December 10, 2008 at 2:09 pm
You can actually use a SQL extended procedure to check the existence of a file, folder or parent folder.
The following code should give you a good place to start
create table #checkfile (FileExist bit, IsDirectory bit, ParentExists bit)
Check_File_Loop: --this is the label
truncate table #checkfile
insert into #checkfile exec xp_fileexist 'c:\boot.ini'
if not exists (select FileExist from #checkfile where FileExist = 1)
BEGIN
WAITFOR DELAY '00:00:01' -- 1 second, set this for the check interval
print 'waited'
GOTO Check_File_Loop --goes back to the label
END
BEGIN
--do your thing witht he file
END
December 10, 2008 at 3:57 pm
Thanks allot. That #checkfile example worked.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply