Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a sybase table which has a column note varchar(1000) null.

The following T-SQL will get the following error if there is a not-null value in note. (sybase is the linked server to the Sybase database)

select * from (sybase, 'select note from table')
select * from (sybase, 'select left(note, 257) note from table')
select * from (sybase, 'select left(note, 1000) note from table')

OLE DB provider 'ASEOLEDB' for linked server 'sybase' returned data that does not match expected data length for column '[ASEOLEDB].note'. The (maximum) expected data length is 257, while the returned data length is 258.

However, it works if the length parameter is less and equal to 256.

select * from (sybase, 'select left(note, 256) note from table')

Also the following SQL works.

exec ('select note from table') at [sybase]

Is it a bug of the Sybase driver?

share|improve this question
add comment

1 Answer

try

select * from OPENQUERY(sybase, 'select left(cast(note as varchar(1000)), 257) note from table')
share|improve this answer
    
It gets the error of "The (maximum) expected data length is 257, while the returned data length is 258". –  u23432534 May 23 '12 at 16:58
    
Whats Sybase version you are connected to, what sybase driver are you using and whats your SQL server –  AmmarR May 24 '12 at 4:42
    
The version is Adaptive Server Enterprise/12.5.4/EBF 16787 ESD#10/P/RS6000/AIX 5.1/ase1254/2159/64-bit/FBO/Mon Nov 2 10:11:59 2009. The driver is the OLEDB driver downloaded from sybase website. –  u23432534 May 24 '12 at 17:47
1  
I am using sybase driver 15.2 and i dont see the problem, your problem looks like its with the driver. I had many problems before with driver 12.5. If you can go for 15.2 try it –  AmmarR May 24 '12 at 18:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.