Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeBCP to SQL Azure complains table is missing?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] FreeBCP to SQL Azure complains table is missing?
  • Date: Tue, 20 Nov 2012 21:51:24 -0500

On Sun, 18 Nov 2012 20:16:59 -0600
Cade Roux <cade AT roux.org> wrote:

> Has anyone used FreeBCP to connect to SQL Azure?
>
> $ freebcp DWSTAGE.BCPTEST in bcptest.txt -f cdr.fmt -S
> serverfromfreetds -U user@azureserver -P password
> Msg 208, Level 16, State 1
> Server 'azureserver', Line 1
> Invalid object name 'DWSTAGE.BCPTEST'.
> Msg 208, Level 16
> General SQL Server error: Check messages from the SQL Server

The message 208 comes from the server. A quick look at freebcp.c shows
argv[1] isn't parsed. It's copied to a struct and used verbatim e.g.

if (dbfcmd(dbproc, "SET FMTONLY ON select *
from %s SET FMTONLY OFF", pdata->dbobject) == FAIL)

My guess is that the account you're logging in with has a default
database, and that database is not the one containing DWSTAGE.BCPTEST.
The Azure server rejects dbname.schema.object syntax, and freebcp has
no -D option because until Azure every TDS server did accept that
syntax.

You could verify that using

$ freebcp 'select db_name()' queryout /dev/stdout ...

As a temporary workaround, I think this would work:

freebcp DWSTAGE.BCPTEST in bcptest.txt \
-O 'USE dbname' \
-f cdr.fmt -S serverfromfreetds -U user@azureserver -P password

A permanent fix would support -D.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page