SQL Server - SQL Server/ bcp 工具如何通信

 

回到顶部(go to top)

问题-BCP通讯

ref: https://stackoverflow.com/questions/40664708/bcp-cannot-connect-to-aws-sql-server-but-ssms-can 

Anyone know a good reason why bcp cannot connect to a sql server hosted by AWS while SSMS can? I have double checked the server and user account details and they both match.

I'm using the generic command to import a csv file:

bcp DB_Name.dbo.Table in "somefile_file.csv" -c -S xxx.rds.amazonaws.com -U username -P xxx -b 1000

The error is:

SQLState = 08001, NativeError = 53
Error = [Microsoft][ODBC Driver 13 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. 
SQLState = 08001, NativeError = 53
Error = [Microsoft][ODBC Driver 13 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.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired

 

回到顶部(go to top)

解答-BCP通讯

The first error shows that bcp uses the Named Pipes protocol to connect to the server. Apparently, this protocol is inaccessible for network connections.

On the client workstation where bcp is run, check SQL Server Configuration Manager and ensure that, in the client configuration list TCP/IP is enabled and prioritised. Strangely enough, bcp doesn't have a command line switch for protocol selection, so this is the only way to manage it I can think of.

P.S. Another option is to specify the server address in the form ip_address,port_number, but I don't think you will find this option particularly attractive.

 

Other comments:

  • In SSMS the network protocol is default. I don't have a local SQL Server. May it be that I need to enable trust server certificate? – chhenning Nov 18 '16 at 3:10 
  • You should have SQL Server client tools on this machine, otherwise how the bcp.exe appeared there, in the first place? And no, this doesn't look like a certificated-related issue. – Roger Wolf Nov 18 '16 at 9:47
  •  
    Finally got SQL Server Configuration Manger to run. The order is Shared Memory (1), TCP/IP (2), and Named Pipes (3). Still, even when I disable Named Pipes I get the same error message. – chhenning Nov 19 '16 at 3:48
  •  
    Put TCP/IP into first position. Also, note that there are 2 separate client configurations, for 32-bit and 64-bit clients, and I'm not sure which one bcp uses. Make sure you have set both of them properly. – Roger Wolf Nov 19 '16 at 4:17

 

扩展-SQL Server / BCP通讯协议种类

官方文档--选择网络协议: https://docs.microsoft.com/zh-cn/sql/tools/configuration-manager/choosing-a-network-protocol?view=sql-server-2014

SQL Server中的命名管道(named pipe)及其使用 :https://www.cnblogs.com/chenxizhang/archive/2009/04/23/1441913.html

 

posted on   frank_cui  阅读(743)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

levels of contents
点击右上角即可分享
微信分享提示