Can't get data using a linked server
-
Tuesday, March 13, 2012 8:12 PM
Hey everyone!
So I've been going at this for a few hours now and I am starting to lose it so I'm turning to you guys :P
Basically, I am trying to query data using an openquery with a linked server but it is not working. Here is what I am doing and the returned error:
SELECT * FROM OPENQUERY(REMEDY,'SELECT ID_de_demande,Date_de_création,Date_de_modification,NomGroupe,TechAffecte,TokenChangeID FROM FM0047___CC_GroupeTechAffecté WHERE TokenChangeID LIKE ''' + @token + '''')
The error being returned is this:
OLE DB provider 'MSDASQL' for linked server 'REMEDY' returned data that does not match expected data length for column '[MSDASQL].NomGroupe'. The (maximum) expected data length is 30, while the returned data length is 31.
I have tried to fix this in many ways (using cast, substr, mid, left...with and without the {fn }) but nothing works. All I get when I do this is this error:
OLE DB provider "MSDASQL" for linked server "REMEDY" returned message "[AR System ODBC Driver]Expected lexical element not found: <identifier>".
So that's it. I am completely out of ideas and will be very grateful to whomever helps me solve this :)
Thanks and have a nice day!
-Jrvd
All Replies
-
Thursday, March 15, 2012 2:54 AM
Hi Jrvd,
Could you please elaborate a bit? What does the linked server ‘REMEDY’ point to? SQL Server, MySQL or Oracle? What’s the data type and length of NomGroupe?
Usually, we need to use a CONVERT/CAST function or a string function to make it match the expected data length.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Get or Request Code Sample from Microsoft
If you have any feedback, please tell us.- Marked As Answer by KJian_ Wednesday, March 21, 2012 2:37 AM

