MSSQL Server and PHP connection
The code is as follows |
Copy Code |
$MCN = Mssql_connect (' 127.0.0.1 ', ' sa ', ' 1 '); mssql_select_db (' HB ', $MCN); |
MySQL database connection
code is as follows |
copy code |
$conn = Mysql_ Connect (' localhost ', ' root ', ' a ') or Die (' MySQL server connection failed '); mysql_select_db (' sa ', $conn); |
The code is as follows |
Copy Code |
$mssql = "SELECT * from BC"; $msquery = Mssql_query ($mssql); Querying MSSQL server for data saving to data if (Mssql_num_rows ($msquery)) { while ($rs = Mssql_fetch_array ($msquery)) { $mysql = "INSERT into VV (id,title) VALUES (' $rs [id] ', ' $rs [title] ')"; MySQL Query statement mysql_query ($mysql);//save data from MSSQL server to MySQL database } } |
Else
{
Echo ' MSSQL server has no data ';
}
/*
Ok finally finished, in fact, the method is very simple is to connect two databases, and then the MSSQL data read out to save to the data, and then save to the MySQL database.
This site original article annotated source www.111cn.net/phper/php.html
*/