Advertisement

02.20.2006 at 11:19PM PST, ID: 21744864
[x]
Attachment Details

Access legacy system via ODBC1.0 using OPENQUERY

Asked by poutses in MS SQL Server

Tags: openquery

Hello all,

I am trying to access a legacy database, through their ODBC driver, that has been implemented using the Microsoft SDK ODBC drivers version 1.0.

In their database they have a field named memo (TableA.memo). This field allows for 1000 characters. The problem is that I can only get 255 characters per field through the ODBC driver, so I only get the first 255 characters. The way I am doing this is SQL Server is:

select  comm, custid from OPENQUERY(LEGACY1, 'SELECT ucase(memo) as comm, custid FROM cust')

As you can understand I am using Linked Servers from SQL Server.

If I use this instead:
select  comm, custid from OPENQUERY(LEGACY1, 'SELECT memo as comm, custid FROM cust')
I get NULL values, or 1 character values instead.

If I use the following:
select  aaa, custid from OPENQUERY(LEGACY1, 'SELECT {fn CONVERT(memo, SQL_LONGVARCHAR)} as aaa,  custid, name FROM cust')
although I explicitly say to use SQL_LONGVARCHAR, I still get 255 characters back

AND if I try to get the last 20 characters using the RIGHT function:
select  * from OPENQUERY(LEGACY1, 'SELECT {fn right(CONVERT(memo, SQL_LONGVARCHAR),20) }, custid, name FROM cust')
I get the values from position 235 to 255.

So how do I get the rest of the string? Is it possible?

I am using the following links to find information, that you might find helpful:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsql_data_types.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcstring_functions.asp


ThanksStart Free Trial
[+][-]02.20.2006 at 11:28PM PST, ID: 16006519

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.20.2006 at 11:31PM PST, ID: 16006521

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: openquery
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.20.2006 at 11:31PM PST, ID: 16006523

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2006 at 02:27AM PST, ID: 16007220

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2006 at 02:35AM PST, ID: 16007254

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2006 at 02:45AM PST, ID: 16007301

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.28.2006 at 10:52PM PST, ID: 16072882

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.01.2006 at 02:26AM PST, ID: 16073769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.07.2006 at 04:01AM PST, ID: 16122666

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32