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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Problems with bulk insert

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-11-22 : 07:15:13
Ronaldo writes "Hello guys,

I have to import a very big txt file into a SQL table. This file has a fixed row lenth, but there is no separators.
When I use the bulk insert command, the SQL just try to import all txt tile into a same row!!!
I tryed to solve it using the BCP, but I didn't find any way to fix a row lenth in order to import each text row into a very single table's row.

Can you guys please help me???


Thank you!!!
Ronaldo"

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-11-22 : 17:51:41
It's a complete bodge (and I would have thought there would be a better way using BCP) but - if you have fixed length fields you could try importing into Access/Excel and doing it from there


steve

To alcohol ! The cause of - and solution to - all of life's problems
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-11-22 : 17:55:17
bcp format files can import fixed-width files no problem. Nigel has some more info here:

http://www.nigelrivett.net/BCP_quoted_CSV_Format_file.html

Basically, you create a format file like he has in that example, only you put "" as the column terminator. Make sure the lengths are correct, and you're all set. You can also use BULK INSERT with a format file. Books Online has more information.
Go to Top of Page
   

- Advertisement -