Sunday, February 6, 2011

Start SQL Server Agent job remotely

Sometimes it is necessary to perform administrative tasks on other SQL Servers, remotely.  As your inventory grows, using Remote Desktop to connect to every one of them can become a little inconvenient.  I administer my instances remotely, as needed.  For example, the statement below can be used to start a SQL Server Agent job remotely, on another SQL Server:

  DECLARE @sql VARCHAR(MAX)
  SET @sql  = ''


  DECLARE @SystemName VARCHAR(50)
  DECLARE @JobName     VARCHAR(50)
  DECLARE @StepName    VARCHAR(50)


  SET @SystemName = 'Other Server Name'
  SET @JobName = 'Agent Job Name'


  SET @sql = '' + @SystemName + '.msdb..sp_start_job @job_name = 
  ''' + @JobName + ''''


  --PRINT 'EXEC '+ @sql
  EXEC (@sql)

Why don't you comment out the EXEC, and un-comment the PRINT before running, just to see how things look.


Please don't forget, you can also use SQL Server Configuration Manager to connect to other servers at a higher level, and administer the services remotely.  See this topic in BOL:  'How to: Connect to Another Computer (SQL Server Configuration Manager)'  .

15 comments:

  1. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also 여성유흥알바

    ReplyDelete
  2. Waow this is quite pleasant article, my sister love to read such type of post, I am going to tell her and bookmarking this webpage. Thanks social work jobs London

    ReplyDelete
  3. If you read through this article, and are still wondering why you are rejected, then after looking in the mirror get out with friends and family and remember what's important. After taking a break for a day or two, then go back to applying for jobs with renewed vigour, and seek some help in your job search.Placement Agencies

    ReplyDelete
  4. I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up.. job board

    ReplyDelete
  5. Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. job posting site

    ReplyDelete
  6. I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up.. termtechreview

    ReplyDelete
  7. The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful globe valve

    ReplyDelete
  8. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks North American Bancard Partners

    ReplyDelete
  9. As soon as I found this web site I went on reddit to share some of the love with them. Unique Dofollow Backlinks

    ReplyDelete
  10. I would like to convey my admiration for your generosity in support of men and women that have the need for help with this particular concern. Your special dedication to getting the message all over had been wonderfully productive and have all the time made professionals much like me to attain their dreams. Your own invaluable tutorial means a great deal to me and additionally to my office workers. Thank you; from everyone of us. Unique Dofollow Backlinks

    ReplyDelete
  11. Yes, I am entirely agreed with this article, and I just want say that this article is very helpful and enlightening. I also have some precious piece of concerned info !!!!!!Thanks. website

    ReplyDelete
  12. I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content. source

    ReplyDelete
  13. Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. blog comment

    ReplyDelete
  14. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. read here

    ReplyDelete