Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSSQL 2005 server instances 1

Status
Not open for further replies.

northrd

Programmer
May 18, 2003
74
AU
Am I just dumb or what? SQLDMO does not list the SQL2005 instances. Any ideas?
 
Nope. SQL-DMO is only 'good for' SQL2000 and lower. For SQL2005, you should use SQL-SMO, which is the 2005 equivalent.

Truth is... I prefer to use SQLCMD to list instances.

Microsoft SQL Server 2005 Command Line Query Utility

To get you started....

use the 'shell and wait' technique for shelling out of vb
redirect the output from the SQLCMD utility.
SQLCMD -L > Servers.txt
Load the servers.txt file to list the sql servers. This will list SQL2000 and SQL2005 instances.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
My only concern about sqlcmd is the somewhat offputting comment in BOL:
Because of the nature of broadcasting on networks, sqlcmd may not receive a timely response from all servers. Therefore, the list of servers returned may vary for each invocation of this option.
and I have been a victim of somewhat erratic behaviour.

I have no idea whether SQL-SMO is any more reliable though.
 
Funny (well, not really!), I used a bit of code posted by strongm that uses the SQL-DMO ListAvailableSQLServers() function. I found that every now and then the "\SQLExpress" is missing and it doesn't connect.

Haven't tried SQL-SMO yet .....

Patrick
 
Well... you learn something new everyday.


Apparently, you cannot use the SQL-SMO object in VB6!

Several years ago, my application used sql-dmo for many different operations. First and foremost was to enumerate a list of servers to connect to. I had a terrible time getting sql-dmo installed on my customers computers. Really, it was awful. This, of course, was before Microsoft made the 'backward compatibility components' available.

In my opinion, sql-dmo is a crutch that some developers use, which allows them to 'not learn' the proper way of doing things. For example, you can use sql-dmo to backup and restore a database. In fact, it's not all that hard to do. But, if you know the correct SQL commands, you don't need to use sql-dmo. You can backup a database using an ADO connection object.

The only exception was listing the available instances. I don't know of any method, using ADO, to list the instances. You can, however, use the 'shell' method that I show in my first post to get them.

Of course, I always allow the user to type in the server name, too. With SQL Server, you can configure it to NOT appear in the list. To see what I mean...

On the server, Click Start -> run
type svrnetcn
click ok

You will see the SQL Server Network Utility
In the Enabled protocols list, click TCP/IP, then click Properties.

You will see the TCP/IP port the SQL Server uses (default is 1433), but there is also a check box for Hide Server.

If Hide Server is checked, then the instance will not appear in the list of enumerated servers.

In my experience, using SQLCMD (with a shell operation) is the most stable way to list the servers.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top