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)'  .

10 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
    Replies
    1. Great Article. Thank you for sharing! Really an awesome post for every one.

      IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      Delete
  2. It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. Viec lam them 365

    ReplyDelete
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. This blog website is pretty cool! How was it made ! Fair Work Australia

    ReplyDelete