Re: FreeBCP to SQL Azure complains table is missing?

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Sun, 18 Nov 2012 20:16:59 -0600
Cade Roux <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.