将 PostgreSQL 9.5 (odbc) 作为链接服务器连接到 SQL Server 2012 时出错

Error connecting PostgreSQL 9.5 (odbc) as Linked Server to SQL Server 2012

我在 SQL Server 2012 上将 PostgreSQL 数据库连接为 Linkd 服务器时遇到错误。

首先,我尝试了 MS Access 的本地连接,效果很好。所以我尝试在我的 SQL Server 2012 上做同样的事情。

我从 PostgreSQL ODBC Driver Repo and the connection test was succesfull http://imgur.com/6dXiwia

设置了 ODBCx64 驱动程序

但是如果我想将它添加为我的 SQL Server Mgmt Studio 中的链接服务器,它无法连接 http://imgur.com/13wihSh

有什么提示无法正常连接吗?

我正在使用:

我找到了适合我的解决方案。

Microsoft SQL Server Management Studio 中的向导没有帮助,我自己设置了连接。我已经用 selects 测试了它并且它有效

这是我使用的代码:

EXEC master.dbo.sp_addlinkedserver 
@server = N'NameShownInMSSQLSrvMgmtStudio', 
@srvproduct=N'PostgreSQL Unicode(x64)', 
@provider=N'MSDASQL', 
@provstr=N'Driver=PostgreSQL Unicode(x64);uid=postgres;Server=SERVERNAME;database=DBNAME;pwd=MyPWD;SSLmode=disable;PORT=5432'

EXEC master.dbo.sp_addlinkedsrvlogin 
@rmtsrvname=N'postgresql',
@useself=N'True',
@locallogin=NULL,
@rmtuser=YourUser,
@rmtpassword=YourPW