Using Sybase ASE BCP to a Remote Server

梦想的初衷 提交于 2019-12-23 03:38:18

问题


I am using BCP to export/import data sometimes to remote servers where i cannot login into the OS, only connect to the DB. I have success with using BCP to connect to a server like this:

bcp mytester.dbo.MyTable in MyTable.bcp -S Sybase157 -U sa -P SyAdmin -n

This of course only works becuase Sybase157 is defined in my sql.ini.

My question:

a) Is it possible to sidestep the whole sql.ini thing and just do something like -S mydb.server.com or -S 123.123.123.123

and if not....

b) what do i need to add to sql.ini in order to connect to a remote server?


回答1:


The peices required for the sql.ini is the hostname(or ip) and port number of the remote server. You must have those two pieces of information at a minimum. You do not need to know the servername of the remote server.

Sybase recommends using the Open Client Directory Service Editor (dsedit) to make changes to the sql.ini file (or interfaces file on unix)

Start > Programs > Sybase Connectivity > Open Client Directory Service Editor

As long as the hostname(or ip) and port are correct, you can choose any valid name for the server you want. This will become the the servername, e.g. -S theNameYouUsedInSqlIni.

This does not change the remote server's servername, or affect the remote server in any way, it only affects connections from your local system.

Adding a Server to the Interfaces File

It's also possible to use LDAP if that is an option in your environment:

Configuring libctl.cfg for LDAP/Using a Directory Service




回答2:


Anawer for (b) : Copy the content of remote server's sql.ini and paste it in your client's sql.ini file. By doing this you will have remote server details in your client's file. You can then do bcp to the remote server using the same command :

bcp mytester.dbo.MyTable in MyTable.bcp -S <remote_host_name> -U sa -P SyAdmin -n

Not clear aboout the question (a) you have to use -U, -P parameters as well only specifying Server won't be enough



来源:https://stackoverflow.com/questions/19529350/using-sybase-ase-bcp-to-a-remote-server

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