SQLCMD -L return no servername

trang 1 Reputation point
2021-07-28T04:06:26.957+00:00

Hi all,

I'm facing an issue when wan to display all servername using sqlcmd -L command. However, it returns no servername. I already install SQLEXPRADV_64_ENU that already include localDB, sql server management studio and other features. could anyone help me on this issue, it's very tricky when I have to read server name from sql server configuration management to connect database from cli.118488-servername.png

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,772 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 44,501 Reputation points
    2021-07-28T06:20:27.267+00:00

    See sqlcmd Utility => Parameter -L[c] => Note

    "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."

    That function haven't ever been reliable

    0 comments No comments

  2. Cris Zhan-MSFT 6,626 Reputation points
    2021-07-28T09:45:11.163+00:00

    Hi,

    As Olaf said, this command has been explained in the documentation, which may not be so practical.

    You can check the SQL Server errorlog to determine the server name (search for "Server name"). According to the version of SQL Server you installed, By default, the errorlog is located at C:\Program Files\Microsoft SQL Server\MSSQLnn.instancesName\ MSSQL\LOG\ERRORLOG, nn corresponds to 15 for SQL Server 2019,14 for SQL Server 2017.

    Or start SSMS locally on the server where SQL Server is installed, and then choose the <Browse for more…> option in the Server name field in the connection window box.

    How to find all localdb instance names please refer to this post.
    https://stackoverflow.com/questions/36157191/sql-server-how-to-find-all-localdb-instance-names

    To connect to the SQL Server database, you can use the server name, or server name\instance name (for the named instance), or the IP address.
    https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/logging-in-to-sql-server?view=sql-server-ver15

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.