-
File Event
Hi,
Can anyone help me with this?
I need to run an SQL job if a specific file exists. Actually, that specific files gets created different time in different day. I need to run the job when the file arrives. Is there any way to do this in SQL? I have done this in seagate scheduler but I need to do it in SQL.
Please help!!!!!!!
Thanks.
-
create your job which needs to run if the file exist. (say Job1)
create a job which runs every 5 minutes or one minute say (job2)
In this jobstep write the following code
DECLARE @result int
EXEC @result = xp_cmdshell 'dir c:\testwww.txt', no_output
IF (@result = 0)
begin
EXEC sp_start_job @job_name = 'Job1'
xp_cmdshell 'ren c:\testwww.txt c:\testwww_Old.txt', no_output
end
-
if you dont like the above method you can also use the undocumented procedure xp_fileexist
-
Thanks very much, I'll try both and let you know which works better.
-
Thanks very much, I'll try both and let you know which works better.
-
Thanks Mak, the first approach worked perfectly except for renaming the file. It says that the syntax is not correct, I got arround with that by using move command.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|