question

Mihira avatar image
Mihira asked

SQL Bulk Copy (bcp) Not Working

Hi All

In a Stored Procedure, I'm trying to export MS SQL table (with 1000 records) to a text file using 'bcp' command.

But, It does not export all the rows, the number of rows exported vary on each execution of the stored procedure and it's always less than 1000.

Please help me on this. This is my piece of code.

Declare @BCP_Str varchar(1000)                    
                    
Set @BCP_Str = 'bcp "VasMagnolia.dbo.FRBT_BCP_Out"                     
    out "E:\DataFiles_1\FRBT.txt" -c -S"1223-VDMS-02A" -U"*****" -P"******" '                    
                    
Exec master.dbo.xp_cmdshell @BCP_Str,no_output                    
sql-server-2005bcpexport-data
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
jezemine 1 avatar image
jezemine 1 answered

you could add -eErrorFile.txt to your cmd line and see what errors are logged.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.