Import SQL server data into Mysql database using php (example)
- // Connect to the SQL server database
- $ Conn = mssql_connect ("localhost", "sa", ""); // server name, user name, and password
- Mssql_select_db ("db_database06", $ conn); // connect to the table_book database
- // Connect to the mysql database
- $ Id = mysql_connect ("localhost", "root", "123456"); // localhost on the local server, root user name, and root password
- Mysql_select_db ("db_database06", $ id );
- Mysql_query ("set names gb2312"); // connect to the shop_book database
- // Query all the contents of the data table book from the SQL server database
- ?>
- SQL Server data import to MySQL database _ bbs.it-home.org
-
-
-
-
- $ Ms_query = mssql_query ("select * from $ db_database", $ conn );
- While ($ msrow = mssql_fetch_array ($ ms_query )){
- $ Name = $ msrow [name]; // set a variable for the output content
- $ Author = $ msrow [author];
- $ Bookconcern = $ msrow [bookconcern];
- ?>
-
Export the content of an SQL Server Data table |
Name |
Author |
Bookconcern |
-
- If ($ Submit2 = true ){
- $ Query = mysql_query ("insert into tb_book (name, author, bookconcern)
- Values ('$ name',' $ author', '$ bookconcern') ", $ id );
- }
- If ($ query = true ){
- Echo "imported successfully !! ";
- } Else {echo "import failed !! ";}
- ?>
-
-
-
-
- $ Query = mysql_query ("select * from tb_book ");
-
-
-
-
- If ($ query = true ){
- While ($ myrow = mysql_fetch_array ($ query )){
- ?>
Imported data |
Name |
Author |
Bookconcern |
|
|
|
|