Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 bcp error when writing to file

Author  Topic 

manouche
Starting Member

2 Posts

Posted - 2009-05-01 : 18:21:07
I am using SQL Server 2005. I am using bcp to do a query and write a file to a folder on the server. Here is the command that I have issued, both from the SQL Management Studio and from the command line. I am using the Administrator account and password, which I have indicated as Administrator/password below:


bcp.exe "select TransactionNumber, DateTime from ILLData..History order by TransactionNumber" queryout "e:\dumpfolder\data.txt" -U Administrator -P password -c

The result is:

C:\Documents and Settings\Administrator>bcp.exe "select TransactionNumber, DateT ime from ILLData..History order by TransactionNumber" queryout "e:\dumpfolder\data.txt" -U Administrator -P password -c SQLState = 28000, NativeError = 18456 Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user 'Administrator'.

I also tried running the bcp statement using the -T switch to do it as a trusted user, but that did not work either.

Can someone enlighten me as to what I need to do?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 18:56:36
You have to pass a valid SQL account to the -U switch. Try using the sa account.

What error do you get when using -T?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

manouche
Starting Member

2 Posts

Posted - 2009-05-01 : 19:27:56
When I use the 'sa' user or run bcp with the -T switch, this is the result:

C:\Documents and Settings\Administrator>bcp "select TransactionNumber, from ILLData..History order by TransactionNumber" queryout "e:\dumpdir\data.txt" -U sa -P mypasswd -c SQLState = HY000, NativeError = 0 Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-02 : 17:39:07
There's a problem with the file or the file's path now.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2009-05-03 : 23:45:17
does e:\dumpdir\data.txt exist?


elsasoft.org
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2009-05-03 : 23:46:06
i mean, does the folder exist?


elsasoft.org
Go to Top of Page
   

- Advertisement -