在shell脚本中SQLCMD无法连接

时间:2017-05-18 15:08:52

标签: sql-server shell sh sqlcmd

我实际上正在编写一个调用sqlcmd的小脚本。 那是:

sqlcmd -S localhost\SQLEXPRESS -E -i Select_All.sql -o All_Tables_Name.txt

当我把它写成cmd行时,效果很好。

当我把它放在.sh文件中时,sqlcmd无法连接到数据库,我得到这些错误:

Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [53]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : 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..

我尝试使用计算机名称或通过'更改-S参数。'但仍然无法运作。

有人可以解释一下,为什么在我将其作为命令行编写时以及从脚本中启动它时会有什么不同请? (例如" sh MyScript.sh")

谢谢。

0 个答案:

没有答案