I have created a linked oledb/odbc connection to Pervasive SQL from SQL SERVER 2012:
我已经从SQL SERVER 2012创建了与Pervasive SQL的链接oledb / odbc连接:
USE [master]
GO
/****** Object: LinkedServer [KSLAP208] Script Date: 2/8/2013 10:38:55 AM ******/
EXEC master.dbo.sp_addlinkedserver @server = N'KSLAP208', @srvproduct=N'Pervasive ODBC Interface', @provider=N'MSDASQL', @datasrc=N'C003', @location=N'localhost'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'KSLAP208',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'use remote collation', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'KSLAP208', @optname=N'remote proc transaction promotion', @optvalue=N'true'
GO
Test Connection is succesful.
测试连接是成功的。
However, when I try to select from a database:
但是,当我尝试从数据库中进行选择时:
select * from [KSLAP208].[C003]..PA_Profile_BASE_1119
I immdiately get just the field names returned and then immediately after that I get this error:
我只是简单地获取返回的字段名称,然后立即得到此错误:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "KSLAP208" reported an error. The provider reported an unexpected catastrophic failure.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "KSLAP208".
What am I doing wrong? Why Can I not select? I am able to see all the databases and tables on the linnked server.
我究竟做错了什么?为什么我不能选择?我能够看到linnked服务器上的所有数据库和表。
if I select a small amount of data select field1,field2 it works without problems.
如果我选择少量数据选择field1,field2它没有问题。
3 个解决方案
#1
14
I think I remember this being an issue when I created a postgresql linked server. I think you may need to recreate the linked server with this set to false (or just change it in the linked server properties->server options):
我想我记得这是一个问题,当我创建一个postgresql链接服务器。我认为您可能需要使用此设置重新创建链接服务器为false(或者只是在链接服务器属性 - >服务器选项中更改它):
EXEC master.dbo.sp_serveroption @server=N'KSLAP208',
@optname=N'remote proc transaction promotion', @optvalue=N'false'
Additionally, try using OPENQUERY
to run this against the link
此外,尝试使用OPENQUERY对链接运行此操作
SELECT *
FROM OPENQUERY(KSLAP208,'SELECT * FROM PA_Profile_BASE_1119');
#2
2
When I access remote tables, I need to have complete 4-part naming. Try this:
当我访问远程表时,我需要完整的4部分命名。尝试这个:
select * from [KSLAP208].[C003].dbo.PA_Profile_BASE_1119
I've never investigated why. I've just gotten in the habit of including all parts.
我从来没有调查过为什么。我刚刚养成了包括所有部分的习惯。
You can get the list of columns using:
您可以使用以下方式获取列列表:
select column_name
from [KSLAP208].[C003].INFORMATION_SCHEMA.COLUMNS
where table_name = 'PA_Profile_BASE_1119'
(and schema_name = whatever if you need that).
(和schema_name =如果你需要的话,无论如何)。
#3
1
Cannot answer why but you could try like this;
不能回答为什么,但你可以尝试这样做;
--link server and login
EXEC master.sys.sp_addlinkedserver N'KSLAP208',N'SQL Server';
EXEC master.sys.sp_addlinkedsrvlogin @rmtsrvname='KSLAP208',
@useself='false',
@rmtuser='username',
@rmtpassword='password';
--DO YOUR JOB HERE
SELECT TOP (10) * FROM [KSLAP208].dbName.dbo.[tableName]
--drop server link and login
EXEC sp_droplinkedsrvlogin 'KSLAP208', NULL
EXEC sp_dropserver 'KSLAP208', NULL;
#1
14
I think I remember this being an issue when I created a postgresql linked server. I think you may need to recreate the linked server with this set to false (or just change it in the linked server properties->server options):
我想我记得这是一个问题,当我创建一个postgresql链接服务器。我认为您可能需要使用此设置重新创建链接服务器为false(或者只是在链接服务器属性 - >服务器选项中更改它):
EXEC master.dbo.sp_serveroption @server=N'KSLAP208',
@optname=N'remote proc transaction promotion', @optvalue=N'false'
Additionally, try using OPENQUERY
to run this against the link
此外,尝试使用OPENQUERY对链接运行此操作
SELECT *
FROM OPENQUERY(KSLAP208,'SELECT * FROM PA_Profile_BASE_1119');
#2
2
When I access remote tables, I need to have complete 4-part naming. Try this:
当我访问远程表时,我需要完整的4部分命名。尝试这个:
select * from [KSLAP208].[C003].dbo.PA_Profile_BASE_1119
I've never investigated why. I've just gotten in the habit of including all parts.
我从来没有调查过为什么。我刚刚养成了包括所有部分的习惯。
You can get the list of columns using:
您可以使用以下方式获取列列表:
select column_name
from [KSLAP208].[C003].INFORMATION_SCHEMA.COLUMNS
where table_name = 'PA_Profile_BASE_1119'
(and schema_name = whatever if you need that).
(和schema_name =如果你需要的话,无论如何)。
#3
1
Cannot answer why but you could try like this;
不能回答为什么,但你可以尝试这样做;
--link server and login
EXEC master.sys.sp_addlinkedserver N'KSLAP208',N'SQL Server';
EXEC master.sys.sp_addlinkedsrvlogin @rmtsrvname='KSLAP208',
@useself='false',
@rmtuser='username',
@rmtpassword='password';
--DO YOUR JOB HERE
SELECT TOP (10) * FROM [KSLAP208].dbName.dbo.[tableName]
--drop server link and login
EXEC sp_droplinkedsrvlogin 'KSLAP208', NULL
EXEC sp_dropserver 'KSLAP208', NULL;