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
 SQL Server Development (2000)
 tab delimited flat file import

Author  Topic 

cherry
Starting Member

6 Posts

Posted - 2004-11-08 : 11:58:33
Hi,

i got a little problem with an import job i have to create. I have to import a file with 4 columns into an SQL Server table. The problem is the file is only one line - new lines are not available and are also not specified for. The only thing that tells you when a new row begins is the number of columns (4). It is tab delimited.

It looks e.g. like this:

id value1 value2 value3 1 hi booh test 2 la foo bar


etc..
Can anyone help me?


Thanks in advance


cherry

nr
SQLTeam MVY

12543 Posts

Posted - 2004-11-08 : 12:08:19
You should be able to do it with bulk insert and a format file
see
http://www.nigelrivett.net/BCP_quoted_CSV_Format_file.html

If not you can import into a text column in a table (is there a crlf at the end? If not make sure the length is not divisible by 4)
Then parse it into the production table.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

cherry
Starting Member

6 Posts

Posted - 2004-11-09 : 04:51:24
Thanks pal, the keyword "bulk insert" helped a lot :)
I created a "bulk insert" task via the Enterprise Manager so I got the import job up and running now - the only problem I still seem to have is the fact that the DTS Package seems to append the Data to the table but I'd like it to clear the table and insert the data completely. Does anyone know how I could do this with the help of the neat DTS features?

Thanks in advance


cherry
Go to Top of Page

cherry
Starting Member

6 Posts

Posted - 2004-11-09 : 04:58:03
Ok, I got it.
Execute SQL Task -> "DELECT FROM table" and a workflow thingy on success run the import.



Thanks anyway
Go to Top of Page
   

- Advertisement -