Home > Database > Mysql Tutorial > SqlServer2005 链接服务器用法

SqlServer2005 链接服务器用法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 18:04:13
Original
1203 people have browsed it

最近项目要用到SqlServer数据库和MySql数据库,因为用的.net开发,于是研究怎样通过怎样通过只连接SqlServer来查询MySql。

查询资料后知道有 sp_addlinkedserver 这个系统存储过程,可通过ODBC连接MySql,于是下载ODBC驱动,这个可通过MySql官网得到,地址:http://dev.mysql.com/downloads/。

安装驱动后配置数据源,这里注意,要用系统数据源,我在用户数据源中配置后数据源能连上MySql,但无法能过SqlServer连接,报错:Data source name not found and no default driver specified,为这折腾了半小时。。

配好数据源后可使用上面的存储过程添加链接服务器,用法可查询联机丛书,这里介绍下用SQL Server Management Studio的配置方法,打开数据库链接的Server Objects(中文版应该是在安全性里面,我用的英文版),Linked Servers,右链添加链接服务器,名称随便取,执行查询语句时要用到,服务器类型选其它数据源,接口用Microsoft OLE DB Provider for ODBC Drivers,产品名称填MySql(有些人说不用填,不过我不填会报错),访问接口字符串填:UID=MySql用户名;PWD=MySql密码,剩下两个不填,然后点左边的安全性,选择最下面的单选按钮,填上刚才的用户名和密码确定,如果没有任何提示,说明添加成功,否则,检查吧。

执询语句的写法:SELECT * FROM OPENQUERY (链接服务器名,'MySql查询语句' ) ;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template