sql server中操作mysql

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:sql server中操作mysql

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

一、安装mysql官方的odbc驱动
mysql-connector-odbc-5.1.7-win32 myodbc驱动补丁(由于驱动自身有bug,发布了补丁)
二、配置odbc

三、创建mysql链接服务

EXEC sp_addlinkedserver 'MySQL50','','MSDASQL','mysql5_test';
EXEC sp_addlinkedsrvlogin 'MySQL50','false','sa','root','4020894';

四、执行相关查询

--查询操作
SELECT TOP 3 * FROM OPENQUERY (MySQL50 ,'select * from abc  ' ) ORDER BY Access_Time desc;
--插入操作
INSERT INTO OPENQUERY (MySQL50, ' SELECT * FROM abc')
values('aaa', 'bbb','ccc','dddd','eeee','2010-11-4','ggggggg')
--更新操作
UPDATE OPENQUERY (MySQL50, 'SELECT Cur_url FROM abc WHERE Pre_url = ''bbb''')
SET Cur_url = 'feifei';
--删除操作
DELETE OPENQUERY (MySQL50, 'SELECT Cur_url FROM abc WHERE Pre_url = ''bbb''') 

发表评论

邮箱地址不会被公开。 必填项已用*标注

13 + 11 =