start a SQL Server job using window command

  • I created a SQL Server job but the user said the job did not have a fixed schedule.  Each month depending when he received the data, then execute the job.  That means each month he would call me to execute the job.  So I want to use osql command to create a bat file.  So when it is ready, the user can start the job himself.

    However I had two problems.  First the osql command requires SQL Server user id and password and I did not want to put in the bat file because it is not secure.  Second I am not even sure osql is the correct command to start the sql server job. 

    Can anyone give me any suggestion?

    Thanks

     

  • Job make a sp that starts the job (sp_start_job?!).  Make a vbs file that uses windows authentication (so no login info is visible).

    I never had to do this but I'm sure it can be made to work that way.

  • I like Ninja's example, but you don't need to use vbs if you're not experienced with it.

    You can use windows authentication and the -E switch on osql for integrated security. Grant the user execute rights on the procedure. Piece of cake.

  • I go with what I know... I never used osql.

     

    Thanks for the tip .

  • I created a SQL table which I allow specific users to insert to. Each user has a spreadsheet with a control button which inserts a request into the SQL table. I have a scheduled job in SQL which executes a stored procedure which checks for new requests each minute (during certain hours) and processes the requests by executing the DTS desired (the requests have a status flag [new, in process, and done] and I only process the TOP 1 [the oldest new status] each cycle.

    ~Michael T

  • First the osql command requires SQL Server user id and password and I did not want to put in the bat file because it is not secure

    You have the option to specify your windows authentication switch too. /E switch can be used instead of giving a user id and password.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

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

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