SQL Server connection problem with SQLCMD command

v1uwarro  于 2023-03-28  发布在  SQL Server
关注(0)|答案(1)|浏览(308)

I have a large database script. Now I am trying to execute that script with SQLCMD command. But after putting the command I am having error: Here is the SQLCMD command:

sqlcmd -S MachineName\DatabaseName -i "D:/sqlscript.sql"

Here is the error:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. . Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

Can you please help me how to solve this problem?

j5fpnvbx

j5fpnvbx1#

-S MachineName\DatabaseName is incorrect.

The bit after \ is supposed to be the instance name, not the database name. For instance names to work you need SQL Browser to be running on that machine also. If you have a default instance then you should remove it completely and just use the machine name.

The database name meanwhile goes in a separate parameter -d (lower-case).

For further reference see the docs .

相关问题