Welcome to Sign in | Help

Re: cum pot afla daca sql server agent ruleaza ?

  •  05-13-2008, 6:37 PM

    Re: cum pot afla daca sql server agent ruleaza ?

    uite un ex folosind C# 3.0 pt SQL 2000 si 2005. Merge cu si oricare alta versiune precedenta daca-l scrii cu foreach. Trebuie sa adaugi o referinta spre System.ServiceProcess.

    using System;
    using System.Linq;
    using System.ServiceProcess;
    class Program
    {
        static void Main(string[] args)
        {
            foreach (var service in ServiceController.GetServices().Where( sc => (sc.ServiceName.StartsWith("SQLAgent") || sc.ServiceName.StartsWith("SQLSERVERAGENT")))) {
                Console.WriteLine(String.Format("SQL Agent: {0} Running: {1}", service.ServiceName, service.Status == ServiceControllerStatus.Running ? "Yes": "No"));
            }
        }
    }
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems