Hi,
I have a text file and having the header of unwanted columns having less than the no. of data column in the txt file. I am using the bulk insert command to insert the text file data into the sql server 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 when we are using above bulk insert.
If there is any solution to insert all the row except header kindly let me know.
Regards,
Nabeel Ahmad
MASTEK
"Making a valuable difference"
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from all computers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MS Sql Server LazyDBA home page