Main Article    SQL Server Integration Services

In SQL Server 2005, Microsoft replaced the familiar command-line tool Osql with Sqlcmd. Both tools perform similar functions, with subtle differences. For example, each tool can connect to a SQL Server instance for direct queries or batch job initiation. And, for my project, they can both perform the invaluable service of listing all listening SQL Server machines on the network. One of Sqlcmd’s subtle differences is that you can use the command-line option /Lc rather than just /L to derive the server list:

sqlcmd /Lc

The c is important in the command because it produces clean output in the server list. If you don’t use the c, the resulting list will contain a header (i.e., Servers:), and each server name will have leading spaces. This situation isn’t ideal for the next phase of my project, in which you load the command output into a table to subsequently use as input to the SSIS package. This package, in turn, will automatically connect to each of these servers to retrieve specific information. You use Sqlcmd solely to get this list of servers. By itself, the command is useful to gain the first level of understanding of the SQL Server machines on your network. However, at this point it reveals nothing more than a server or instance name.

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

i used sqlcmd /Lc or /L and returned null, but i do have sql installed..??

billykanthug

Article Rating 4 out of 5

I am not sure unless maybe you have a combination of security settings that are preventing browsing to the servers...Firewall ports blocked, SQL Browsing disabled, listening on ports other than default, hidden servers?

rlandrum

Article Rating 4 out of 5

 
 

ADS BY GOOGLE