无法使用链接服务器连接到 SQL Azure

发布于 2024-12-01 07:08:56 字数 895 浏览 3 评论 0原文

我一直在这里关注这篇文章:

http://blogs.msdn.com/b/sqlcat/archive/2011/03/08/linked-servers-to-sql-azure.aspx

了解如何设置从 SQL Server 2008 R2 到 SQL Azure 实例的链接服务器。我使用 SQL Native Client 10.0 作为 ODBC 驱动程序,并根据显示的默认数据库判断连接是否有效;但是,当我尝试按照上面的文章建议建立链接服务器时;我收到以下错误:

链接服务器“Azure_Test”的 OLE DB 提供程序“MSDASQL”返回消息“[Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序”。

现在我看到一些论坛帖子(不幸的是没有结论)表明这可能是 64 位问题。有人成功从本地实例设置到 SQL Azure 的链接服务器吗?

编辑:大卫的回答确实是正确的;只是想我会分享这个我发现你现在可以使用链接服务器完成的令人惊叹的事情:

DELETE OPENQUERY (AzureTest, 
'SELECT * FROM [AzureDB].static.MyTable');

INSERT OPENQUERY (AzureTest, 
'SELECT * FROM [AzureDB].static.MyTable')
SELECT *
FROM static.MyTable

SELECT * FROM OPENQUERY(AzureTest, 'SELECT * FROM [AzureDB].static.MyTable')

I've been following this article here:

http://blogs.msdn.com/b/sqlcat/archive/2011/03/08/linked-servers-to-sql-azure.aspx

on how to setup a Linked Server from SQL Server 2008 R2 to an SQL Azure instance. I am using SQL Native Client 10.0 as the ODBC driver and judging by the default databases that are shown the connection is valid; however when I attempt to establish a linked server as the above article suggests; I get the following error:

OLE DB provider "MSDASQL" for linked server "Azure_Test" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".

Now I've seen a few forum posts (Nothing conclusive unfortunately) suggesting it may be a 64bit issue. Has anyone successfully setup a Linked Server to SQL Azure from a local instance?

EDIT: Davids answer was indeed correct; just thought I'd share this awesomeness I found you can do now with a linked server:

DELETE OPENQUERY (AzureTest, 
'SELECT * FROM [AzureDB].static.MyTable');

INSERT OPENQUERY (AzureTest, 
'SELECT * FROM [AzureDB].static.MyTable')
SELECT *
FROM static.MyTable

SELECT * FROM OPENQUERY(AzureTest, 'SELECT * FROM [AzureDB].static.MyTable')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹过旳痕迹 2024-12-08 07:08:56

我已按照您链接到的文档中列出的步骤完成了此操作。

下面是让它为我工作所需的两个 SQL 语句:

EXEC master.dbo.sp_addlinkedserver @server = N'Azure_ODBC1',@srvproduct=N'Any', @provider=N'MSDASQL', @datasrc=N'MY Azure'
GO

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'Azure_ODBC1',
@useself=N'False',@locallogin=NULL,@rmtuser=N'piqBackup@azureServer',@rmtpassword='########'
GO

我将 ODBC 连接设置为系统 DSN(我最初将其设置为用户 DSN,但遇到了一些问题)。我只是使用了我的服务器名称(前面没有“tcp:”)——azureServer.database.windows.net。一旦我设置了 DSN 并运行了上面的三个语句,它就工作得很好。我可以毫无问题地执行这个语句:

SELECT * FROM Azure_ODBC1.piqBackupData.dbo.BackupData

我不确定这是否有帮助 - 但我希望它有帮助。祝你好运!

I have done this, following the steps that are listed in the document that you linked to.

Here were the two SQL statements that I needed to make it work for me:

EXEC master.dbo.sp_addlinkedserver @server = N'Azure_ODBC1',@srvproduct=N'Any', @provider=N'MSDASQL', @datasrc=N'MY Azure'
GO

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'Azure_ODBC1',
@useself=N'False',@locallogin=NULL,@rmtuser=N'piqBackup@azureServer',@rmtpassword='########'
GO

I set my ODBC connection up as a SYSTEM DSN (I originally set it as a User DSN and had some issues). I just used my server name (no 'tcp:' in front) -- azureServer.database.windows.net. Once I set up the DSN and ran the three statements above, it worked fine. I could execute this statement without issue:

SELECT * FROM Azure_ODBC1.piqBackupData.dbo.BackupData

I'm not sure if this helps or not - but I hope it does. Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文