How to write using BCP to a remote SQL Server?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 12:11:15

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

The DBName is the name of the database, you need to use -S option to provide the server (or server\instance) name.

From MSDN:

-S server_name [\instance_name] Specifies the instance of SQL Server to which to connect. If no server is specified, the bcp utility connects to the default instance of SQL Server on the local computer. This option is required when a bcp command is run from a remote computer on the network or a local named instance. To connect to the default instance of SQL Server on a server, specify only server_name. To connect to a named instance of SQL Server, specify server_name\instance_name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!