[英]Error = [Microsoft][SQL Server Native Client 11.0]
This error appear when write this code in sql server 2012: 在sql server 2012中编写以下代码时,会出现此错误:
EXEC xp_cmdshell 'bcp "select [ProductID],[ProductName],[UnitPrice] from Northwind.dbo.Products" queryout "d:\bcptest2.txt" -T -c -t, '
Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. 错误= [Microsoft] [SQL Server Native Client 11.0]建立与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.
检查实例名称是否正确以及SQL Server是否配置为允许远程连接。 For more information see SQL Server Books Online.
有关更多信息,请参见SQL Server联机丛书。
How to solve it? 怎么解决呢?
The query you have made works correctly. 您进行的查询可以正常工作。 However, you have not enabled TCP/IP within SQL Server.
但是,您尚未在SQL Server中启用TCP / IP。 This can be done by doing the following:
这可以通过执行以下操作来完成:
Your query should now work correctly. 您的查询现在应该可以正常工作。
See the following msdn document for further info. 有关更多信息,请参见以下msdn文档。 Enable TCP/IP Network Procotol for SQL Server
为SQL Server启用TCP / IP网络Procotol
Please let me know if this doesn't resolve the issue as there may be other configuration required. 如果这不能解决问题,请告诉我,因为可能需要其他配置。
EDIT: 编辑:
Can you try running the following from the command line (ie cmd.exe): 您可以尝试从命令行(即cmd.exe)运行以下命令吗?
bcp "select [ProductID],[ProductName],[UnitPrice] from Northwind.dbo.Products" queryout "d:\bcptest2.txt" -T -c -t
Let me know if this works for you or not (so we can see if it's BCP or xp_cmdshell causing the issue). 让我知道这是否对您有用(因此我们可以看看是BCP还是xp_cmdshell引起了该问题)。 Can you also look into the following:
您还可以研究以下内容吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.