dbTalk Databases Forums  

import a text file to SQL server

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss import a text file to SQL server in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CR
 
Posts: n/a

Default import a text file to SQL server - 06-24-2004 , 04:18 AM






I have typed to import a text file to SQL server 2000 with MDAC2.8 installed.
The text file is with different record width in each row.
I use the 'add connection' and choose the data source 'Text File (Source) and my file.
In the text file properties, Fixed field, file type: ANSI, Row delimiter:{CR}{LF}.
After click <Next> button, the preview selects the first row width (65 characters) as the next line width. So the part of the third line has found in the second line!

How can I settle the problem?

The first six lines of my file:
001234517744080090ABCDEFGHI HK LTD 17/07/2004081812
011707200400117/07/2004
02170720040010000100001REMCHK 1234567890100282 0001 2500.20CB765432101234567892004/07/172004/07/17HKDMABCDE HONG KONG YACHT CLUB 01234567896543210123456789ABCDE HONG KONG YACHT CLUB ABCDE HONG KONG YACHT CLUB IT JUST FOR TESTING IN THE REMARK FIELDS
031707200400100001RAACHK 1234567890100282 0001185600002 2000.00 2000.00 ABCDE HONG KONG YACHT CLUB
031707200400100001RAACHK 1234567890100282 0001185600003 500.20 2000.00 ABCDE HONG KONG YACHT CLUB
041707200400100001RARCHK 1234567890100282 0001RWOBC001 0.00 ABCDE HONG KONG YACHT CLUB



Regards,
CR


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: import a text file to SQL server - 06-24-2004 , 04:48 AM






Different row widths and the text file driver are two things that do not
play well together. You can however work around this by using a little
something from the site.

(PaddingTask.zip)

Archive
(http://www.sqldts.com/Default.aspx?273)


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"CR" <CR (AT) discussions (DOT) microsoft.com> wrote

Quote:
I have typed to import a text file to SQL server 2000 with MDAC2.8
installed.
The text file is with different record width in each row.
I use the 'add connection' and choose the data source 'Text File (Source)
and my file.
In the text file properties, Fixed field, file type: ANSI, Row
delimiter:{CR}{LF}.
After click <Next> button, the preview selects the first row width (65
characters) as the next line width. So the part of the third line has found
in the second line!
Quote:
How can I settle the problem?

The first six lines of my file:
001234517744080090ABCDEFGHI HK LTD 17/07/2004081812
011707200400117/07/2004
02170720040010000100001REMCHK 1234567890100282 0001
2500.20CB765432101234567892004/07/172004/07/17HKDMABCDE HONG KONG YACHT CLUB
01234567896543210123456789ABCDE HONG KONG YACHT CLUB ABCDE HONG KONG
YACHT CLUB IT JUST FOR TESTING IN THE REMARK FIELDS
Quote:
031707200400100001RAACHK 1234567890100282 0001185600002
2000.00 2000.00
ABCDE HONG KONG YACHT CLUB
Quote:
031707200400100001RAACHK 1234567890100282 0001185600003
500.20 2000.00
ABCDE HONG KONG YACHT CLUB
Quote:
041707200400100001RARCHK 1234567890100282 0001RWOBC001
0.00 ABCDE HONG KONG YACHT CLUB



Regards,
CR




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.