I used to use this sqlcmd to run my query and it is working fine up until I ran it in a different computer. I got the following error:
>sqlcmd -S localhost -d master -E -h -1 -i my-query.sql Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server . . 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..
Specify the exact SQL Server named instance instead of using localhost. So, I change from
sqlcmd -S localhost...
tosqlcmd -S .\SQLEXPRESS...`.