Error on BCP

Last Post 07 Jan 2003 02:22 PM by chubby. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
MPatel_SQL
New Member
New Member

--
07 Jan 2003 05:59 AM
Hello,

I have two different problem with BCP.

1. See the following command I am using to run BCP - queryout option. When I am using same thing on command prompt, it works fine but when I tried to run through query analyzer using xp_cmdshell sp, it says 0 rows affected and it didn't created any file. Its not giving me any error. Any Idea?

exec xp_cmdshell 'bcp "select * from pubs..authors" queryout c:\authors.txt -c -q -SSQLDev -U"Test1" -P"12345"'

This is on one machine.

2. Second one -- This is on another machine.

It works fine when I user this on command prompt

bcp "pubs.dbo.authors" out authors.txt -c -q -SSQLDev -U"test1" -P"12345"


But gives errors when I run this on command prompt:

bcp "select * from pubs.dbo.authors" queryout c:\authors.txt -c -q -SSQLDev -U"test1" -P"12345"

This is the Error:

Bcp has generated errors & will be closed by Windows. You will need to restart the program.

Any Idea ?

Note : I tired 1 & 2 on two different machine. Both machine are connect to SQL Server 7 but SQL 2000 client installed.

Any suggestion..

Thanks
MPatel
chubby
New Member
New Member

--
07 Jan 2003 02:22 PM
I dont think quote are needed for User and pwd ..so take out quotes like shown below.

bcp "select * from pubs.dbo.authors" queryout c:\authors.txt -c -q -SSQLDev -Utest1 -P12345.

Again I would always recommend to capture the error info on log file. here is the sample format.

bcp "Select * from db..table" queryout C:\authors.txt -c -o c:\authors.log -t "\t" -Sserver -Uusersname -Ppassword

Try the other one also if you need.
You are not authorized to post a reply.

Acceptable Use Policy