Hi friends,
+++++++++++School(B):Students++++++++++
No.of students:120
No.of classes:2
No.of teachers:5
Hostel facility:available
++++++++++School(G):Students+++++++++++
No.of students:300
No.of classes:3
No.of teachers:10
i have got lot of data like this. i need to insert it into SQLServer by using perl programming
I need to insert into sql_Table by
Type of school,No.of students,No.of classes,No.of Teachers,Hostelfacility
pls anyone help me to align data into SQL
i already tried this coding;pls give some other way to enhance my coding
#MsSQL Server2008 #!/usr/bin/perl use strict; use DBI; my $FIRST="+++++++++++School(B)"; my $SECOND="+++++++++++School(G)"; my $j=0; my $dbh = DBI->connect('dbi:ODBC:SQLServer', undef, undef, {PrintError + => 0, RaiseError =>0}); my $sth1 = $dbh->prepare("CREATE TABLE test11 ('$Type[0]','$Students[1 +]','$class[2]','$Teachers[3]','$hostel[4]')"); + $sth1->execute; foreach $line (<FILE>) { chomp $_; ($event[$kk],$data[$kk])=split(/: /,$line); $l= ++$kk; } while($j<=$l) { if($event[$j] eq $FIRST) { $Type[0]="BOYS"; my $x=1; ++$j; } if($event[$j] eq $SECOND) { $Type[0]="GIRLS"; ++$j; } if($event[$j] =~ m/^No.of Stud /ig) { $Students[1]=$data[$j]; ++$j; } if($event[$j] =~ m/^No.of class /ig) { $class[2]=$data[$j]; ++$j; } if($event[$j] =~ m/^No.of teach/ig) { $teachers[3]=$data[$j]; ++$j; } if($event[$j] =~ m/^Hostelfacility/ig) { $hostel[4]=$data[$j]; ++$j; } my $sth = $dbh->prepare("insert into test11 values('$Type[0]','$Studen +ts[1]','$class[2]','$Teachers[3]','$hostel[4]')"); $sth->execute; ++$j; } #i need to enhance my coding efficiency pls help me #Thanks in advance
In reply to Data insert into SQL Server? by sowraaj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |