Importing via sqlcmd errors out PS C:\Users\administrator.INTERNAL\Desktop&gt; sqlcmd -S SQLMAIN\MSSQLSERVER -i rdmdb.sql
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : SQL Server Network Interfaces: Connection string is not valid [
87]. .
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 11 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 i
f SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..


I opened the port 1433 to allow remote connections in the firewall. I also disabled the firewall with no success.

I double checked server name and instance and they all check out.
If you are really sure that your Server name is correct you can still try to specify the port explicitly like that:

sqlcmd -S SQLMAIN,1433 -i rdmdb.sql 


If you run your SQL Server database as a Contained Database it might be necessary to login to the database direclty using -d:

sqlcmd -S SQLMAIN,1433 -d yourDatabase -i rdmdb.sql 


Make sure that you really can access your SQL Server on the specified port. You can try this using telnet.

telnet SQLMAIN 1433


If you don't use a windows login you might need to provide your username and passowrd using -U (Username) and -P (Password). 

sqlcmd -S SQLMAIN,1433 -d yourDatabase -U User -P Password -i rdmdb.sql 


If you use the integrated authentication, you can also try the Trusted Connection using -E

sqlcmd -S SQLMAIN,1433 -d yourDatabase -E -i rdmdb.sql 


Please be also be sure that the specified input file can be accessed and found at your specified location.

Hopefully this will answer your question and your getting your connection to work. :-)