Monday, September 24, 2012

Get All Running Instances of Sql Server

Que:- Get All Running Instances of Sql Server?

Sol:-

Step 1. add Com refrence to  sqlserver dmo.

sqldmo.dll can be found at
"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.DLL"

Step 2.add this code in page_load event

protected void Page_Load(object sender, EventArgs e)
    {
        NameList sqlservers = new SQLDMO.Application().ListAvailableSQLServers();
       
        foreach (string sql in sqlservers )
           {
                Response.Write(sql +"<br/>");
           }
    }

No comments:

Post a Comment