Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked server returned data that does not match length... 1

Status
Not open for further replies.

gbaughma

IS-IT--Management
Staff member
Nov 21, 2003
4,773
US
I have a linked Access database, and I'm trying to copy all of the data from one table to another.

I have set up the fields with the same names and order, and the one field that's crashing the routine is a text field.

The error that I'm getting is:

Code:
Msg 7347, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' for linked server 'LIMSBE' returned data that does not match expected data length for column '[LIMSBE]...[Results].MethodName'. The (maximum) expected data length is 40, while the returned data length is 7.

The command that I'm running is:
Code:
INSERT INTO NTSWeb.dbo.Results
SELECT * FROM [LIMSBE]...[Results]

The field is set to nvarchar(20) on the SQL end... it's just a 20-character text field on the access end.

I have tried adding T8765 to my startup parameters for the SQL Server (although not for the SQL Agent or SQL Browser)....

I have also tried doing a CONVERT and a CAST in my query; it all gives the same results.

Any thoughts or suggestions on this? It's about 600,000 records.....



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
What version of SQL are you using. Specifically... what service pack?

Code:
Select ServerProperty('ProductVersion'),
       ServerProperty('ProductLevel')



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
  • Thread starter
  • Moderator
  • #3
ProductVersion: 10.0.1600.22
ProductLevel: RTM

I'm doing this on Server 2008 Developer's edition.



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
  • Thread starter
  • Moderator
  • #4
Ugh... OK, I just tried:

Code:
SELECT * INTO NTSWeb.dbo.ResultsTemp
FROM LIMSBE...RESULTS

... letting SQL create the table the way IT wanted to.

Still same error.

Code:
Msg 7347, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' for linked server 'LIMSBE' returned data that does not match expected data length for column '[LIMSBE]...[Results].MethodName'. The (maximum) expected data length is 40, while the returned data length is 7.



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
One thought if you are trying to import from SQL to Access...
NVARCHARs actual length is twice that of VARCHAR. Try changing the size of the column on the Access end to 40.
 
  • Thread starter
  • Moderator
  • #6
I'm going from Access to SQL with a linked Access database.

My research is showing that it has to do with Jet 4.0 not reporting the metadata correctly... they had a hotfix for SQL 2000 for it, but evidently the problem still exists in 2008.


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
  • Thread starter
  • Moderator
  • #7
... meanwhile, I tried changing that field to varchar(20) instead of nvarchar(20)... but I don't think that's going to help... I'm running the query again now.


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
  • Thread starter
  • Moderator
  • #8
Nope. That didn't do it. Same error.


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
Can you try listing the columns? Something like this...

Code:
INSERT INTO NTSWeb.dbo.Results
  (Col1, Col2, Col3, MethodName, Col5)
SELECT Col1, Col2, Col3, Convert(nvarchar(20), MethodName), Col5 
FROM [LIMSBE]...[Results]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
  • Thread starter
  • Moderator
  • #10
I did that... same error. It's really weird. I tried:

CONVERT(NVARCHAR(20),MethodName) AS MethodName

I tried CAST(MethodName AS NVARCHAR(20))

Do you know if there is a way for SQL to tell me *WHICH* record it failed on? Perhaps a simple fix to that one record would fix things.....



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
does this work?

Code:
SELECT * FROM OPENQUERY(LIMSBE,'SELECT * FROM Results')

If it does, then maybe this....

Code:
INSERT INTO NTSWeb.dbo.Results
SELECT * FROM OPENQUERY(LIMSBE,'SELECT * FROM Results')


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
  • Thread starter
  • Moderator
  • #12
Exact same error. :(

There must be an offending record... if I could only figure out which one....



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
I'd be curious to know what the output of this is:

Code:
sp_columns_ex 'LIMSBE', 'Results'
[code]

I don't necessarily recommend posting the results here, but I wonder what it shows for the Type_Name, Column_Size and Buffer_Length for the MethodName column.

-[url=http://blogs.lessthandot.com/index.php/All/?disp=authdir&author=10]George[/url]

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
  • Thread starter
  • Moderator
  • #14
Hmmmm.... interesting. The TYPE_NAME is VarChar, the COLUMN_SIZE is 20, the BUFFER_LENGTH is 40

I wonder why the BUFFER_LENGTH is greater than the COLUMN_SIZE....

Would it fix it if I set the data type in SQL to VarChar(40)? (I think I tried this once to no avail....)



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
  • Thread starter
  • Moderator
  • #15
On further investigation, I see that all VarChar types have a buffer length of 2x the column size.



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
It could be that Access stores all string columns as unicode so it requires 2 bytes per character. I'm not too familiar with Access.

How is the column defined in the Access database?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
  • Thread starter
  • Moderator
  • #17
It's defined as a text field with a length of 20.



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
  • Thread starter
  • Moderator
  • #18
George:

I believe I found it. It was a corrupted record. It had FUNKY values in it.

I'd give you 50 stars if I could for all your help over the last couple of weeks.



Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top