我需要在LINKED服务器中从Mssql到Mysql的更新查询

时间:2012-05-18 05:53:28

标签: mysql sql-server

其实我需要将Mssql连接到Mysql,幸运的是我用MSSQL 2008 R2链接服务器连接了Mysql

现在我想在两个数据库中一次编写一些更新查询 当我尝试这个查询时

update products set Stock=A.Stock from
  (Select * FROM OPENQUERY(MYSQL,'Select * From products where Id=8')) A
  inner join products B on b.Id=a.Id

MSSQL的行从MYSQL

更新

我还需要将MSSQL更新为MYSQL

请帮助我,我在过去4天工作

1 个答案:

答案 0 :(得分:6)

MYSQL到MSSQL UPDATION:

update products set Stock=A.Stock from
(Select * FROM OPENQUERY(MYSQL,'Select * From products')) A
inner join products B on b.Id=a.Id



UPDATE employee
SET LastName = ( Select FirstName from employee where FirstName = (SELECT * FROM
OPENQUERY(MYSQL, 'Select FirstName from employee where IndividualId=3')))

MSSQL到MYSQL更新:

UPDATE OPENQUERY (database, 'SELECT Stock FROM wings.products WHERE id =1') 
SET Stock=999;