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
 Other SQL Server Topics (2005)
 BCP Script format error

Author  Topic 

Mountain
Starting Member

1 Post

Posted - 2009-09-10 : 16:40:04
Hi all,

I am trying to use BCP script to load data from a TXT file(Pipe deliminated) imported through FTP site. when i try to load the file that i recived from the FTP site i get the error "Error = [Microsoft][SQL Native Client]String data, right truncation".

however when i open the same file in Wordpad and then save it as TXT it loads the file without issues so i belive its a format error in my BCP line that needs to be corrected?

my BCP script is as follows.
bcp "[server].[dbo].[table]" in "d:\folder\folder\file.txt" -F 1 -c -t "|" -r -C RAW -h "TABLOCK" -T

my columns in the txt file is seperated by a "|" and the row is seperated by something that looks like a small square


i am trying to automate this process so that i do not have to open the file everytime to save it in the right format.

any help would be much appreciated.

regards,

M

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-14 : 18:04:33
quote:
however when i open the same file in Wordpad and then save it as TXT it loads the file without issues

This usually indicates that the file needs to be converted from UNIX to DOS format. It's possible that WordPad is doing this automatically when you save the file.
Google for a unix2dos untility or a codepage convertor.

Or you can try changing the -r option to cater for the difference in the line feed/carriage return.
Go to Top of Page
   

- Advertisement -