[thelist] SQL Server Export As Query? [solved]
Rob Smith
rob.smith at THERMON.com
Wed Aug 4 11:26:24 CDT 2004
This is a lame work around but this is how I eventually did it. I basically
need a whole bunch 'a INSERT commands.
First, I exported the file via DTS to a .csv file. Created my table. then
did:
$filename = "/..(absolute path)../test.csv";
$handle = fopen($filename, "r");
$contents = explode("\r\n", fread($handle, filesize($filename)));
for ($i = 0;$i<count($contents)-1;$i++)
{
$line = explode(",",stripslashes($contents[$i])); // comma
deliminted csv
mysql_query("INSERT INTO ofnav VALUES
(".$line[0].",".$line[1].",".$line[2].",".$line[3].",".$line[4].",".$line[5]
.")");
}
fclose($handle);
I now have 2,000+ rows of stuff in a matter of about 3 seconds. Sure beats
copy and pasting.
Thanks anyhow,
Rob
More information about the thelist
mailing list