I NEED TO INSERT DATA INTO SQLSERVER PLS HELP ME TO MAKE EFFICIENT MY PROGRAM

NOw I'M CURRENTLY USE WINDOWS SQL2008R2, AND WINDOWS2003

I HAVE BULK OF DATA LIKE THIS,I NEED TO INSERT INTO SQLSERVER

CURRENTLY I TOOK 50min FOR 4250 ROWS

I WOULD LIKE TO REDUCE THE TIME NEARLY A MINUTE

PLS HELP ME TO REDUCE THE EXECUTION TIME

======== SCHOOL (B): MALE ========= SCHOOL_NAME :ABCDEFGH NAME_OF_STUDENT :RAJ ID_NUMBER :9632587410 ADDRESS :23,7TH STREET PINCODE :03214 MOBILE_NUMBER :4563210789 LAND_LINE :0123859674 FATHER'S_NAME :SHIVA MOTHER'S_NAME :JAYA ANNUAL_INCOME :520000 CHARACTER :GOOD ======== SCHOOL (G): GIRLS ========= SCHOOL_NAME :QWERTY NAME_OF_STUDENT :FATEMAH ID_NUMBER :10234567890 ADDRESS :635,9TH STREET PINCODE :63520 MOBILE_NUMBER :9632105478 FATHER'S_NAME :NHOORE MOTHER'S_NAME :JAVATHI ANNUAL_INCOME :420000 CHARACTER :GOOD #PLS NOTE THAT THE LAND_LINE NUMBER OF GIRLS SCHOOL IS MISSING #!/usr/bin/perl use strict; use warnings; use DBI; my $k=0; my @event; my @data; my $a="BOYS"; my $b="GIRLS"; my $dbh = DBI-> connect('dbi:ODBC:SQLServer','new', undef, {PrintError + => 0, RaiseError =>0}); my $sth1 =$dbh->prepare("DROP TABLE SOWND1"); $sth1->execute(); my $sth =$dbh->prepare("CREATE TABLE SOWND1(TYPE varchar(300),SCHOOL_N +AME varchar(300), NAME_OF_STUDENT varchar(300),ID_NUMBER varchar(300),ADDRESS varchar(30 +0),PINCODE varchar(300), MOBILE_NUMBER varchar(300),LAND_LINE varchar(300),FATHER'S_NAME varcha +r(300),MOTHER'S_NAME varchar(300), ANNUAL_INCOME varchar(300),CHARACTER varchar(300))"); $sth->execute(); my $lines; my @files = <C:/strawberry/perl/bin/SCHOOL/STUDENTS/*>; foreach $filee (@files) { open(FILE,$filee); foreach $lines (<FILE>) { chomp ($lines); $lines =~ tr/\n//; $lines=~ s/^\======== SCHOOL \(B\): MALE =========/Type : BOYS/ig; $lines=~ s/^\======== SCHOOL \(G\): FEMALE =========/Type : GIRLS/ig; ($event[$k], $data[$k]) = split /\s*:\s*/,$lines; ++$k; } my $j=0; while($j<=$#event) { if($data[$j] eq $a) { my $sth2 = $dbh->prepare("INSERT INTO SOWND1 values('$data[$j]','$data +[$j+1]','$data[$j+2]', '$data[$j+3]','$data[$j+4]','$data[$j+5]','$data[$j+6]','$data[$j+7]', '$data[$j+8]','$data[$j+9]','NE','$data[$j+10]')"); $sth2->execute(); $j=$j+10; } if ($data[$j] eq $b) { my $sth2 = $dbh->prepare("INSERT INTO SOWND1 values('$data[$j]','$data +[$j+1]','$data[$j+2]', '$data[$j+3]','$data[$j+4]','$data[$j+5]','$data[$j+6]','$data[$j+7]', +'$data[$j+8]', '$data[$j+9]','$data[$j+10]','$data[$j+11]')"); $sth2->execute(); $j=$j+11; } ++$j; } $#event=-1; $#data=-1; }

In reply to Data insert into DB by sowraaj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.