Search code examples
sybasesap-asebcp

Using Sybase ASE BCP to a Remote Server


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?


Solution

  • 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