1

我正在尝试使用 SQL Server 2008 R2 上的 openquery 从进度数据库中选择一些数据,但我收到了此错误消息。

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "progress" 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 "progress".

我做了一些测试,发现问题出在一个特定的列上,它是一个 varchar 列。该列有大约 30 列,对他们来说,选择工作正常。这是我的查询:

SELECT * from openquery(progress, 'select DescricaoProduto from MP.pub.IMPproduto')

我试图做一些不同的选择,但没有一个奏效。例如:

SELECT * from openquery(progress, 'select Cast(DescricaoProduto as char(100)) as DescricaoProduto from MP.pub.IMPproduto')

知道该怎么做吗?

4

2 回答 2

2

Progress data is all variable length. Progress applications routinely "over-stuff" fields. SQL tools often object to that. The Progress db maintains a SQL-WIDTH attribute which can be updated using the "dbtool" utility provided by Progress. If you are going to pull data from a Progress database you must use this tool periodically.

http://knowledgebase.progress.com/articles/Article/P24496?q=how+to+use+dbtool+to+modify+sql-width&l=en_US&c=Product_Group%3AOpenEdge&fs=Search&pn=1

The easy path is to start PROENV (found in the OpenEdge program group) then run "dbtool dbname" and select option 2.

Or you can use the following SQL:

ALTER TABLE ALTER COLUMN SET PRO_SQL_WIDTH ;

if you know which table & column is causing the problem and you do not need to scan everything.

于 2013-11-11T16:31:37.777 回答
1

解决此问题的另一种方法是使用 SUBSTRING,如下所示:

SELECT * from openquery(progress, 'select substring(DescricaoProduto,1,100) as DescricaoProduto from MP.pub.IMPproduto')

因此,如果该列定义为 30 个字符并且该列包含 50 个字符,则 substring(col, 1,50) 实际上将检索所有 50 个字符。

于 2013-11-22T08:02:09.680 回答