kangz Posted July 21, 2011 Share Posted July 21, 2011 Hi, I have a linux server that I am using to run mysql 5 with a demographics database on it. I would like to update another remote database running ms sql server (2005 i think) with the same demographic data, all this from within the mysql server (or using php script if necessary) since that is where I have control. Any idea how to achieve that? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/242513-update-ms-sql-server-from-mysql/ Share on other sites More sharing options...
Muddy_Funster Posted July 21, 2011 Share Posted July 21, 2011 It can be easily done using a php script, you just need to make sure that you have the relevent libraries enabled, then just run an update on the msSql from within the select loop from the MySql. Quote Link to comment https://forums.phpfreaks.com/topic/242513-update-ms-sql-server-from-mysql/#findComment-1245587 Share on other sites More sharing options...
kangz Posted July 21, 2011 Author Share Posted July 21, 2011 It can be easily done using a php script, you just need to make sure that you have the relevent libraries enabled, then just run an update on the msSql from within the select loop from the MySql. I have the libraries enabled (mssql for php) and i would love to have the part where you say "..from within the select loop.." thats where i figure out i would have a problem on how to go about it. Quote Link to comment https://forums.phpfreaks.com/topic/242513-update-ms-sql-server-from-mysql/#findComment-1245616 Share on other sites More sharing options...
Muddy_Funster Posted July 21, 2011 Share Posted July 21, 2011 When you perform a select on the MySQL you will loop through the returned records using a WHILE loop. Within the WHILE loop you assign the record returned to your update query and perform that there and then. I have no idea how comfortable you are with PHP and SQL so don't know how much more you need, nor do I have any table information to use to produce any example code. Here is some Psudo that should help: MySQL_Select = SELECT fieldsByName FROM table Execute MySQL_Select OR (Show Error Message) WHILE MySQL_Select returns Rows { MSSql_Update = UPDATE table SET (MSSqlFieldName = FieldReturnedFrom MySQL_Select) [repeat SET(...) for each field to be updated] Execute MSSql_Update OR (Show Error Message) } Quote Link to comment https://forums.phpfreaks.com/topic/242513-update-ms-sql-server-from-mysql/#findComment-1245640 Share on other sites More sharing options...
kangz Posted July 22, 2011 Author Share Posted July 22, 2011 When you perform a select on the MySQL you will loop through the returned records using a WHILE loop. Within the WHILE loop you assign the record returned to your update query and perform that there and then. I have no idea how comfortable you are with PHP and SQL so don't know how much more you need, nor do I have any table information to use to produce any example code. Thanks. I am wondering though how you are going to update the remote server which is mssql from the php script. If you can help me with the entire code both on php and mysql i will appreciate so much. Im "intermediate level" with both. You can assume the following details: mysql server : localhost (testsvr0) database: demographics_dbo table: tbl_biodata (id, fname, dob, staffid) mssql server: mssqlsvr0 database: employeedb table: tbl_biodata (id, fname, dob, staffid) Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/242513-update-ms-sql-server-from-mysql/#findComment-1246076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.