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
 General SQL Server Forums
 New to SQL Server Programming
 BULK INSERT / DTS package

Author  Topic 

nabeela
Starting Member

3 Posts

Posted - 2007-06-29 : 06:28:12
Hi,

I have a text file and having the header that have fewer columns as compare to second rows column in the txt file (also the actual table columns). I am using the bulk insert command to insert the text file data into the sql server 2000 table by using the below query:

BULK INSERT Mytable FROM 'e:\Mytext.txt'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n'
)

Mytext.txt contains, lets assume like this ---

Name;FName;year;Sex
Robin Singh;Robin;2007;M;Graduate;Working;India
John Mathew;John;1999;M;Post Graduate;Working;USA
Rita Jhonson;Rita;2000;F;Graduate;Housewife;UK

When we are running above query it is inserting from the 3 row i.e. John Mathew skipping the 2 row. What I come to know from the above result that if the header has less columns in the txt file then it considers 2nd row as 1st row that's why it's skipping the 2nd row.

Amazing when I use the bulk insert by using DTS package its inserting the rows properly. It’s real fun. So any idea guys, if yes can anybody tell me the way to get the DTS package script for the bulk insert or any other solution to insert all the row except header.

Thanks in advance.
Regards,
Nabeel Ahmad















































Regards,















Nabeel Ahmad

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-29 : 12:26:08
Dup: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=85751

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -