0

I'm new to MS SQL server, doing tryouts to connect to MS-SQL Server through Linux system. For this I had installed odbc driver & configured odbc.ini.

By using sqlcmd, I'm able to connect to SQL server. Following command used:

sqlcmd -D -U$DBUSER -P$DBPASSWD -S$SERVER

But I'm trying to use bcp for bulk copy which did not work. Command:

bcp $DBNAME.dbo.$TABLE1 out $FILE1 -c -m 100 -e $TABLE1.out.bcperr -U$DBUSER -P$DBPASSWD -S$SERVER

But this command gives error

CTLIB Message: - L6/O8/S5/N3/5/0: ct_connect(): directory service layer: internal directory control layer error: Requested server name not found

I had tried to add -D option to bcp but it gives error, invalid option -D. How I can use bcp so that, it will work same as sqlcmd?

Pravin
  • 121
  • 2
  • **1.** are you sure `$FILE1` is accessible however you have that variable resolving from the SQL Server itself? What is the value of `$FILE1`? Is needs to be access from the SQL Server level and not a local path on the machine when you run the command so user a network location or a path local on the SQL Server which has access. **2.** `-e` is supposed to go to a FILE (not a table) that is again accessible from the SQL Server level and not the local machine you are running the BCP from I thought. These are quick thoughts so give a try and please report back if that helps you any. – Pimp Juice IT Jul 31 '16 at 06:59
  • Thank you for comment 1. `$FILE` is output datafile, `out` operation performing using `bcp` 2. Sorry for confusion of `$TABLE` with -e, I'm using `$TABLE` variable along with file name just for my understanding. If table name is _abc_ then error file will be _abc.out.bcperr_. – Pravin Aug 02 '16 at 12:29

0 Answers0