无法使链接服务器在Sql Azure中工作

Dav*_*ich 17 sql-server azure azure-sql-database

我们正在使用Azure的试用版.我们正在尝试从我们的SQL 2012内部执行跨服务器查询.

我们似乎将我们的本地2012与Azure相关联.当我进入Server Object- > Linked Servers在管理工作室时,我看到了我们的Azure数据库.

但是,如果我尝试打开目录和表,我会收到一条错误消息

Reference to database and/or server name in 'Perseus.sys.sp_tables_rowset2' is not supported in this version of SQL Server

**Perseus是我们目录的名称Azure Sql.

从本地连接运行查询:

SELECT *  FROM [azureDBServer].[Perseus].[dbo].[accounts]
Run Code Online (Sandbox Code Playgroud)

结果是:

    OLE DB provider "SQLNCLI11" for linked server "azureDBServer" returned message 
"Unspecified error". Msg 40515, Level 16, State 2, Line 1 Reference to database and/or
 server name in 'Perseus.sys.sp_tables_info_90_rowset' is not supported in this version of
 SQL Server.
Run Code Online (Sandbox Code Playgroud)

内部相同的SQL 2012 Server能够通过跨服务器查询和通过链接服务器查看其结构来连接到我们的内部2008.

我从本文中了解到Azure支持链接服务器.

所以我对错误感到迷茫.我们的管理员认为我们可能拥有Web-Sql帐户和业务SQL帐户.此Azure Web与Business SQL过时的堆栈链接意味着SQL版本不是问题,而是Azure提供链接服务器之前的日期.

所以,我试图了解是否

a)我们没有设置提供SQL链接的权利?

b)我们受到审判的限制?

c)我们受Web SQL版本的限制吗?

d)其他什么?

Dil*_*are 17

需要执行下面提到的三个存储过程来添加SQL Azure.使用下面这些存储过程我能够查询SQL azure.

EXEC sp_addlinkedserver
@server='PROD',
@srvproduct='',     
@provider='sqlncli',
@datasrc='azureserver.database.windows.net',
@location='',
@provstr='',
@catalog='database name'


EXEC sp_addlinkedsrvlogin 
@rmtsrvname = 'PROD',
@useself = 'false',
@rmtuser = 'Azure login',
@rmtpassword = 'password'

EXEC sp_serveroption 'PROD', 'rpc out', true
Run Code Online (Sandbox Code Playgroud)

  • 我可以添加一下 server = 'PROD' 与我的情况下的数据源值相同吗?多谢。 (2认同)
  • 优秀!正是我需要的 (2认同)

小智 14

从SQL Management添加链接服务器时,您无法选择设置默认数据库.所以使用下面的东西

EXEC sp_addlinkedserver
@server='name for referring locally', -- here you can specify the name of the linked server
@srvproduct='',     
@provider='sqlncli', -- using SQL Server native client
@datasrc='AzureMachineName.database.windows.net',   -- add here your server name
@location='',
@provstr='',
@catalog='yourdatabasename' 
Run Code Online (Sandbox Code Playgroud)

我认为这很有效.

  • 我收到错误:无法找到存储过程'sp_addlinkedserver'.还使用Azure sql db. (5认同)