November 30, 2009 at 9:21 am
Hi,
Is it possible to import a pipe | delimited file int a table. The format of the file is as below:
Data||||||Data|||||Data
Data|||Data|||||||||||||||||Data
Data||Data|||||||Data
Any help would be appreciated.
Thanks
Bob
November 30, 2009 at 9:29 am
try this..
BULK INSERT testtbl
FROM 'f:\orders\lineitem.txt'
WITH
(
FIELDTERMINATOR =' |',
ROWTERMINATOR =' |'
);
November 30, 2009 at 9:31 am
easily bob;
if the table exists, or if you create a staging table, there's no porblem; you want to use BULK INSERT command to do it. your example seemed to be a 23 column table with many nulls. which is fine, my example is just a two column table.
CREATE TABLE BULKSTUFF(COLUMNLIST VARCHAR (10),COL2 INT)
BULK INSERT BULKSTUFFFROM 'c:\Export_o.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = '|',
ROWTERMINATOR = '{slash-n}', --the forum will not display FIRSTROW = 1
)
Lowell
December 1, 2009 at 12:46 am
Hi
Thanks, that works great.
Bob
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply