SqlServer配置链接服务器LINKSERVER:ODBC连接MySQL数据库
SqlServer配置链接服务器LINKSERVER:ODBC连接MySQL数据库
操作步骤:
打开ODBC数据源配置页面,点击【添加】按钮,选择:MySQL ODBC 8.0 ANSI Driver
配置MySQL连接信息:
打开SQLServer管理器,添加LinkServer(链接服务器),
访问接口选择:Microsoft OLE DB Provider for ODBC Drivers
产品名称、数据源选择:BeeTMS( 上面配置的ODBC数据源)。
必须选择【使用此安全上下文建立连接】,输入连接MySQL的账号和密码。
添加链接服务器成功后,输入SQL测试:
SQL Code:
SELECT * FROM OPENQUERY(BEETMS,'SELECT hy_no,dept_name FROM bee_tms.tb_tms_hy')
//来源:C/S框架网 | www.csframework.com | QQ:23404761
//来源:C/S框架网 | www.csframework.com | QQ:23404761
Add Link Server(SQL Script):
扫一扫加微信
SQL Code:
/****** Object: LinkedServer [BEETMS] Script Date: 05/04/2021 11:38:50 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'BEETMS', @srvproduct=N'BeeTMS', @provider=N'MSDASQL', @datasrc=N'BeeTMS'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'BEETMS',@useself=N'False',@locallogin=NULL,@rmtuser=N'firs001',@rmtpassword='########'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'collation compatible', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'rpc', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'rpc out', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
//来源:C/S框架网 | www.csframework.com | QQ:23404761
EXEC master.dbo.sp_addlinkedserver @server = N'BEETMS', @srvproduct=N'BeeTMS', @provider=N'MSDASQL', @datasrc=N'BeeTMS'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'BEETMS',@useself=N'False',@locallogin=NULL,@rmtuser=N'firs001',@rmtpassword='########'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'collation compatible', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'rpc', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'rpc out', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'BEETMS', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
//来源:C/S框架网 | www.csframework.com | QQ:23404761
扫一扫加微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网