x
login about faq Site discussion (meta-askssc)

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                    
more ▼

asked Oct 22 '09 at 08:30 AM in Default

Mihira gravatar image

Mihira
11 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Oct 23 '09 at 01:51 AM

jezemine 1 gravatar image

jezemine 1
11

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1834
x36
x26

asked: Oct 22 '09 at 08:30 AM

Seen: 1650 times

Last Updated: Oct 23 '09 at 09:27 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.