PHP converts MSSQL data to MySQL database

Source: Internet
Author: User
Tags mssql mssql server mysql query mysql database

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
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.