简体   繁体   中英

Creating a Linked Server instance from MS SQL Server to a Google Cloud MySQL server

I have been attempting to connect the databases of a MSSQL server to a Google Cloud MySQL server so I can do joins between them. I've set up the correct ODBC on my machine and tested the connection, which works fine. But when I go to set up the linked server in the MS Server Management Studio, I get error 7303

The linked server has been created but failed a connection test. Do you want to keep the linked server?

Additional information: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL". OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". (Microsoft SQL Server, Error: 7303

What might I be missing here? I ensured the ODBC driver I have is 64 bits (same as the MS Sever Management I have) but configured the System DSN for 32 bits as well. Is there something I must configure on the Google Cloud Server to make this link work? Since the DSN connection test passes, I assume it must be some failure within the Server Management Studio itself. Thank you!

EDIT: Here is the script used to create the linked server:

USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'SERVERNAME', @srvproduct=N'MSDASQL', @provider=N'MSDASQL', @datasrc=N'server-name'

GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'SERVERNAME', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
USE [master]
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'SERVERNAME', @locallogin = NULL , @useself = N'False'
GO

To be honest, in fact this is a client error.
You don't have the MSDASQL driver installed on your client machine, or possibly you only have a version that your client tool can't connect to -- such as 32-bit while you're running a 64-bit client.

It is normal that you can create the Linked Server without an error.
The driver is not checked by sp_addlinkedserver; it just creates the relevant table entries.

To easily see what drivers you do have, try the visual ODBC Data Sources tool.
You can start the process of creating a DNS and get see all the driver names. It may have only the long names, but those also work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM