如何使用BCP写入远程SQL Server? [英] How to write using BCP to a remote SQL Server?

查看:140
本文介绍了如何使用BCP写入远程SQL Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于连接主机名的远程SQL Server。



BCP建议使用

  bcp C:\test\yourfile.txt -c -T -t -b 


但是,当我尝试这样做时,它不会连接到DBName,因为这不是有效的别名。我收到本机错误2。



如何运行BCP,但指定要连接的Internet /网络地址,而不是MSSQL服务器名称?

解决方案


如何运行BCP但要指定要连接的Internet /网络地址,而不是MSSQL服务器名称?


您可以指定IP地址(此处仅为127.0.0.1)而不是服务器名称。



bcp C:\test\yourfile.txt中的DBName.dbo.tablename -c -T -t -S 127.0 .0.1\instance



如果您确实只想访问IP端口,请使用逗号分隔IP地址和端口



bcp C:\test\yourfile.txt中的DBName.dbo.tablename -c -T -t -S 127.0.0.1 ,60905



当然,在这种情况下,您需要知道实例使用的端口,并且应该将实例设置为使用固定端口


I have a remote SQL Server with a hostname I am using to connect to.

BCP suggests to use

bcp DBName.dbo.tablename in C:\test\yourfile.txt -c -T -t

However when I try this it does not connect to DBName as that is not a valid alias. I get native error 2.

How to I run BCP but specify an internet / network address to connect to, not an MSSQL server name?

解决方案

How to I run BCP but specify an internet / network address to connect to, not an MSSQL server name?

You can specify the IP address (here just 127.0.0.1) instead of the server name.

bcp DBName.dbo.tablename in "C:\test\yourfile.txt" -c -T -t -S"127.0.0.1\instance"

If you truly want to go IP\port only then use IP address and port separated by comma

bcp DBName.dbo.tablename in "C:\test\yourfile.txt" -c -T -t -S"127.0.0.1,60905"

Of course in that case you would need to know the port the instance is using, and your instance should be set to use a fixed port

这篇关于如何使用BCP写入远程SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆