[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

SP /Trigger - File Search to begin jobs.

We are using FTP to transfer a number of files from another machine(the type and details are not important) to SQL Server.  
At the end of the nightly process I will receive a Text file called READY.txt, which will let me know that the process has completed from that server.

I would like to create a sp that checks every five minutes for that file.  I understand the job schedule portion.  

THE QUESTION:  How do I create either a DTS package or a sp to search for this file to start my evening's / morning's processes?  I am looking for something that states:  
          If C:/FTP/READY.txt exists
          Then go to the next step
          Else keep waiting until my time is up.

Thanks.

         
0
brine
Asked:
brine
  • 2
1 Solution
 
nigelrivettCommented:
something like this in an sp scheduled every 5 mins.

create table #a (s varchar(1000))
insert #a
xp_cmdshell 'dir /B C:/FTP/READY.txt'

if exists (select * from #a where s like ...)

look at the result you get in #a for the file - you might want to check the file date too.
0
 
nigelrivettCommented:
more like

create table #a (s varchar(1000))
insert #a
exec master..xp_cmdshell 'dir C:/FTP/READY.txt'

if exists (select * from #a where s like '%'READY.txt%')


(I do a like instead of /B with = because you will probably want to look at other attributes too).



0
 
brineAuthor Commented:
Thanks ... Sorry I took so long to respond, but I needed to make time to test.  
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now