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
 Transact-SQL (2000)
 Inserting Unformatted Text File into Temp Table

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-08 : 14:12:21
Guys,

I have an Unformatted Text file that I need to import into SQL Server2000. Can you guys help me how to import this data into a Temp Table in sql server 2000. Each field is separated by a Semi Colon in a row. I am using VB.NET . Here is the sample file.
For Example:
If we take a first row that is “21” then in that ‘CJDS ADVERTISING-DENVER’ needs to go to “ADVERTISER” in TempTable and “PO BOX 1999” needs to go to ‘ADDRESS’ in Temp Table and so on. Appreciate your help.
Thanks,

21;1;CJDS ADVERTISING-DENVER ;PO BOX 1999;42ND FLOOR;1999 BROADWAY,DENVER, CO 80202;;CO; …
22;KJDS;TV;N;KJDS-TV - LAKEWOOD, CO;COLUMBINE/JDS SYSTEMS;1999 BROADWAY, SUITE 4000;DENVER, CO 80202-3050;;JDS; …
23;KJDS-TV - LAKEWOOD, CO;COLUMBINE/JDS SYSTEMS;1999 BROADWAY, SUITE 4000;DENVER, CO 80202-3050;; …
24;THIS IS A BIAS INVOICE THAT PRINTS ON TOP THIS IS A BIAS INVOICE COMMENT THAT PRINTS ON TOP / LINE 2; …
24;THIS IS A BIAS INVOICE COMMENT THAT PRINTS ON TOP THIS IS A BIAS INVOICE COMMENT THAT PRINTS ON TOP / LINE 2; …
25;WE WARRANT THAT THE BROADCAST; …
25;INFORMATION SHOWN ON THIS INVOICE IS; …
25;WITHIN TWO MINUTES OF THE ACTUAL TIME.; …
31;CJDS-ATLANTA;TEST SALESPERSON;INVOICE TEST;EI TEST PRODUCT;990228;1;;82474;9902;990201;990228;980201;990228;;;;;;;;0;2081;448;;EIPRO; ;;;;;;;; …
32;THIS IS AN ORDER/INVOICE COMMENT; …
41;1;MTWTFSS;1000;1030;;10000;;;;;; …
51;Y;990204;4;1005;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
51;Y;990213;6;1028;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
51;Y;990215;1;1015;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
51;Y;990224;3;1025;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
41;3;MTWTFSS;1000;1030;;10000;;;;;; …
51;Y;990205;5;1005;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
51;Y;990216;2;1025;30;EI TEST INVOICE;10000;;;;;;;;;;;N;;;;; …
41;6;MTWTFSS;1000;1030;;10000;;;;;; …
51;N;990207;7;0000;30;;10000;;;;;;;;;10000;;N;;;;; …
52;DID NOT AIR; …
51;N;990208;1;0000;30;;10000;;;;;;;;;10000;;N;;;;; …
52;DID NOT AIR; …
51;N;990219;5;0000;30;;10000;;;;;;;;;10000;;N;;;;;



Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-08 : 15:12:49
U can use Import Export Wizard


Srinika
Go to Top of Page

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-08 : 15:14:45
No, Import Export Doesn't work because i need to import the data in to proper fileds in the table.
Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-08-08 : 15:29:59
quote:
Originally posted by saidev

No, Import Export Doesn't work because i need to import the data in to proper fileds in the table.
Thanks



Yes it will. Please explain why you think it won't work.

Tara Kizer
Go to Top of Page

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-08 : 15:57:24
I cannot use Import/Export Wizard because Each row has multiple fields seperated by semicolon. And also if you look at some other rows some of the data is missing it was just semicolon instead of fields. So if i use Import Wizard then the data goes into different fields rather than it needs to go into exact fields in temp table.
is this clear..?
Thanks,
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-08-08 : 16:01:46
You haven't selected the correct options in the wizard then.

Tara Kizer
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2006-08-09 : 16:01:55
saidev,

In order to import the data, it needs to have every row in the same format. Your sample file doesn't appear to be set up that way. For example, looking at the row beginning with '32', it's definitely not in the same format as the lines above and below it.

Ken
Go to Top of Page
   

- Advertisement -