Many of the programs I’ve written depend on the SQL Agent Service. To make sure that no one has configured this service to run manually (I’ve encountered many idiosyncrasies in my job), I rely on the piece of code that Listing 1 shows. This code ensures that the SQL Agent Service is running. You can also transform it into a startup procedure, as Listing 2 shows.
Share your SQL Server discoveries, comments, problems, solutions, and experiences with products and reach out to other SQL Server Magazine readers. Email your contributions (400 words or less) to email@example.com. Please include your phone number. We edit submissions for style, grammar, and length. If we print your submission, you’ll get $50.