从本地数据库表创建bcp格式文件 - 连接错误

时间:2014-12-04 09:20:21

标签: sql sql-server sql-server-2014

我需要从本地数据库表创建一个格式文件,但是当我尝试在cmd中运行命令时出现连接错误。这是我正在使用的命令:

bcp OrderDatabase.dbo.Orders format nul -c -f D:\Format\Orders.fmt -T

我收到以下错误:

SQLState = 08001, NativeError = 2
Error = [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [2].
SQLState = 08001, NativeError = 2
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.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Server Native Client 11.0]Login timeout expired

我已检查过Services.msc,而SQL Server确实是“已启动”。我还检查了Sql Server配置管理器,SQL Server状态为“正在运行”,启动模式为“自动”。

本地数据库的连接字符串是:

Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Tools_TextileMagazine\CSharp_Template\Tools_TextileMagazine\OrderDatabase.mdf;Integrated Security=True

任何可能出错的想法?​​

1 个答案:

答案 0 :(得分:4)

添加-S参数,如下所示: http://msdn.microsoft.com/it-it/library/ms162802.aspx

所以你的连接字符串将是:

bcp OrderDatabase.dbo.Orders format nul -c -f D:\Format\Orders.fmt -T -S localhost\V11.0

我假设您从连接字符串中命名为istance: V11.0