Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Truncate data problem with OPENQUERY

Author  Topic 

LaurieCox

158 Posts

Posted - 2007-10-05 : 09:42:29
Hi,

I have an application that uses a Cache data base. The data is exposed to sql server via a linked server.

In the Cache database they have data columns that can be up to 32395 characters long. When I do a simple select query like this:

select Intervention_text from cwsavpmtest_live..system.Intervention_data

… I get the error message:

Server: Msg 7341, Level 16, State 2, Line 1
Could not get the current row value of column '[cwsavpmtest_live]..[system].[Intervention_data].intervention_text' from the OLE DB provider 'MSDASQL'.
[OLE/DB provider returned message: Requested conversion is not supported.]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IRowset::GetData returned 0x80040e1d].

I figured out that I could get around the problem with an OPENQUERY like this:

SELECT *
FROM OPENQUERY(cwsavpmtest_live, 'select left(Intervention_text,32395) from Intervention_data’)

The error goes away, but I only get the first 255 characters of the data. I don’t really need all 32395 chars (I figure 4000 chars would be acceptable).

This is not a display problem in Query Analyzer. I set the maximum characters per column to 8000 on the Results tab of the Option dialog. Also I have a stored procedure that is called by Reporting Services and it is only sending 255 characters to the report.

The stored procedure has code that looks like this:

CREATE TABLE #Intervention_Data
(ID varchar(254),
FACILITY Int,
INTID Int,
Intervention_Text varchar(4000),
Intervention_Name varchar(50))

SELECT @QueryString =
'INSERT INTO #Intervention_Data SELECT * FROM OPENQUERY(' + @LinkedServer +
',''select ID, FACILITY, INTID, left(intervention_text ,4000), ' +
'Wiley_Intervention_ID from Intervention_Data where facility = ' +
cast(@FACILITY as varchar(10)) + ''')'

EXEC(@QueryString)

I have tried making the Intervention_Text column in the temp table both "text" and "ntext" data type with the same result.

Does anybody have any clues about how I can make this work?

Thanks,

Laurie

Note: When I link to the Cache database using Access, Access interprets the long fields as being of type "Memo" and I can see all of the data.

edited because tap and tab are not the same word.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-05 : 09:55:44
What's the result of the below query?

SELECT *
FROM OPENQUERY(cwsavpmtest_live, 'select Convert(Varchar(4000), Intervention_text) as Intervention_text from Intervention_data’)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

LaurieCox

158 Posts

Posted - 2007-10-05 : 10:00:28
quote:
Originally posted by harsh_athalye

What's the result of the below query?

SELECT *
FROM OPENQUERY(cwsavpmtest_live, 'select Convert(Varchar(4000), Intervention_text) as Intervention_text from Intervention_data’)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



Still Truncates …

I get the following:

Help the parents find ways to assist in the advancement of the client's maturity and independence (e.g., give the client age-appropriate privileges, encourage activities outside of home, require the client to be responsible for specific jobs or tasks in t

In Access I can see that the data should actually be:

Help the parents find ways to assist in the advancement of the client's maturity and independence (e.g., give the client age-appropriate privileges, encourage activities outside of home, require the client to be responsible for specific jobs or tasks in the home).
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-05 : 11:17:42
Put a stored procedure on cwsavpmtest_live..system which returns just the first, say, 4,000 characters of that column, and call the Sproc (on that server) instead of querying it directly?

But I am struggling with the concept that you cannot query that table directly.

Just to check: the Current database and the remote / linked one are BOTH SQL Server database?

Kristen
Go to Top of Page

LaurieCox

158 Posts

Posted - 2007-10-05 : 11:32:18
quote:
Originally posted by Kristen

Put a stored procedure on cwsavpmtest_live..system which returns just the first, say, 4,000 characters of that column, and call the Sproc (on that server) instead of querying it directly?

But I am struggling with the concept that you cannot query that table directly.

Just to check: the Current database and the remote / linked one are BOTH SQL Server database?

Kristen


There in lies the problem. The remote database is a Cache Database. Not SQL Server.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-05 : 11:33:53
Ah, I see, sorry didn't twig that.

Might be an issue with its ODBC driver then?

Kristen
Go to Top of Page

LaurieCox

158 Posts

Posted - 2007-10-05 : 12:35:17
quote:
Originally posted by Kristen

Ah, I see, sorry didn't twig that.

Might be an issue with its ODBC driver then?

Kristen


What kind of issues would I be looking at? The ODBC driver is kind of a black box for me. I created the DSN by running a stock crystal report from the application. This automatically generated the DSN.

I have posted this question over at the user group intersystems.public.cache. It's a moderated group and the question hasn't been posted yet. Also it looks kinda slow, so I am not sure when (if ever) I will receive an answer.

It was the only (semi live) forum I could find for Cache … oh well if anybody has any hints or ideas where I could look for the answer it would be appreciated.

Thanks,

Laurie

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-05 : 13:27:54
"What kind of issues would I be looking at?"

I was thinking that perhaps there were bugs in the ODBC driver, or limits imposed by it.

Or possibly come configuration parameters ("Max permitted length of column data" would be a good one to discover existed!!)

Kristen
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-10-05 : 13:41:08
You would probably be better off have someone write a program in a native Cache application to extract the data to a file, and then load that file into SQL Server.



CODO ERGO SUM
Go to Top of Page

LaurieCox

158 Posts

Posted - 2007-10-10 : 14:12:26
After wandering around google, looking at the Caché SQL Reference, reading about ODBC and OLE/DB and a thousand other things that didn't help me with my problem, I for no other reason then desperation started playing with the openquery again.

In my original query I used the LEFT function. Harsh Athalye had suggested that I try CONVERT and that didn't work. So I tried CAST and that worked!!!!

I am a little bit curious as to why cast worked when convert didn't. Any guesses?

Laurie
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-10 : 14:21:57
Probably just the way they have chosen to implement it. Maybe CONVERT isn't supported at all?

Anyways, the original error was "Requested conversion is not supported" and I'm sure as hell going to read the error message more carefully in future!

Kristen
Go to Top of Page
   

- Advertisement -