windows service to trigger a sql server agent job

  • Hello All

    I have created a windows service which will trigger a sql server agent job when a specific file arrives in to the file server folder, so that the job will pick it up the file and process to our staging tables, but somehow my service is not triggering the job. if anyone come across the same situation or you familiar with this approach, request your support

    Thanks

  • Most likely issue, other than you just coded things poorly, is security stuff.

    What error is your process throwing if any? Is it running and doing nothing? Is the job firing and not doing what is expected or throwing an error?

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • Hi Kevin

    Thanks for your reply, its doing nothing but in the event log its written below

    Fault bucket , type 0

    Event Name: CLR20r3

    Response: Not available

    Cab Id: 0

    Problem signature:

    P1: myservice.exe

  • This isn't a SQL Server related problem, and we don't have access to your source code in any case. Post up on an appropriate forum. Or come up with a different solution.

    Powershell perhaps?: http://superuser.com/questions/226828/how-to-monitor-a-folder-and-trigger-a-command-line-action-when-a-file-is-created

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • JohnNash (11/17/2016)


    Hello All

    I have created a windows service which will trigger a sql server agent job when a specific file arrives in to the file server folder, so that the job will pick it up the file and process to our staging tables, but somehow my service is not triggering the job. if anyone come across the same situation or you familiar with this approach, request your support

    Thanks

    How is the windows service running the job? An easy way I've run SQL Agent jobs from an external program is to make a connection to the database with a user that has one of the SQL Server Agent fixed database roles in the MSDB database, and execute the stored proc:

    EXEC msdb.dbo.sp_start_job @job_name = 'job name here'

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply