bcp not working properly

  • I ran the following script to copy data from fms_out_ct table into a text file at d:\fms\fms_out.txt using the format from d:\fms\fmsout.fmt.  There are only 340 rows in the fms_out_cf table.  But after running this script, I had over 1800 rows in my text file.  Why?

    execute master..xp_cmdshell 'bcp "select * from fms_out_cf order by out_seq_num" queryout d:\fms\fms_out.txt -f d:\fms\fmsout.fmt -Smyserver -Umyuser -Pmypassword'

    go

  • A couple things to check:

    What is returned from Query Analyzer when you run select * from fms_out_cf order by out_seq_num against the target database?

    If it is, in fact, only 340 I'd take a look at my format file to make sure I'm not using premature row indicators... turning horizontal data vertical, if you will.

    Then ask if the user in use defaulting to a different database (perhaps you're looking at a test database while querying in production, or vice versa).

    2 cents,

    SJT

  • What happens if you run the same bcp without the format file, with -c?

    There is no "i" in team, but idiot has two.
  • Thank you all for the ideas!  I've played around with the script and took the server username and password (who was not a SA account) out and ran the script by loggin in as the SA and it worked fine after that.  I still don't know why.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply