accesser2003
08-01-2008, 09:40 AM
If my computer name is Elephant, and I want to look for all the SQL instances at this computer, How can I get those?
|
View Full Version : How can I list all the instances available in a server machine accesser2003 08-01-2008, 09:40 AM If my computer name is Elephant, and I want to look for all the SQL instances at this computer, How can I get those? KenHigg 08-01-2008, 09:48 AM (There must be an appropriate elephant joke for this but I just can't think of one at the moment - :) ) georgedwilkinson 08-01-2008, 09:53 AM Through Enterprise Manager. DCrake 08-03-2008, 11:37 PM Here is a samll function that searches for all available servers connected to the host pc You will need to add Microsoft SQLDMO Object Library to your references first. Public Function ListConnectedSQLServers() Dim i As Integer Dim oNames As SQLDMO.NameList Dim oSQLApp As SQLDMO.Application Set oSQLApp = New SQLDMO.Application Set oNames = oSQLApp.ListAvailableSQLServers() SysServerCount = oNames.Count If SysServerCount = 0 Then ArrayServers(0) = "LOCAL" Else For i = 0 To SysServerCount - 1 ArrayServers(i) = oNames.Item(i) Next i End If End Function In this sample I declared an array and a interger variable, ArrayServers and SysServerCount respectively. The code enumerates and passes the SQL server names to the array. Which can be used to populate a list box or combobox later. If the servercound is greater than zero. This is used to warn the user that no SQL servers could be detected. CodeMaster::cool: |