Category Archives: SQL Trivia

List all SQL Server installed on a particular network

Believe me, remembering server names is one major headache when you are new to a certain environment on a job.

Imagine you just joined a company and faintly remember server name but not sure if
that’s correct, here is a way to list all the servers on a particular network:

1. click on start, and select run (or press windows logo + R simultaneously)
2. type cmd to launch dos prompt window
3. depending on the version of SQL server type

a) pre SQL 2005 Servers: osql -L
b) post SQL 2005 Servers : sqlcmd -L

and then press enter.

List Servers using MS Cmd Prompt

To add further either of above commands are internally run when we use SSMS too.
Checkout the screenshot:

SQL Server List

Thinking Hat says:

This is not a first option at all and rather may be just a fun exercise.
You will be better of contacting immediate supervisor as some of shops have 1000’s of servers on a particular domain (that you are part of) and might take a long time to retrieve the results.