http://www.itpub.net/forum.php?mod=viewthread&tid=1780983&ordertype=1
用Rtrim()
select * from OPENQUERY(MYSQLAPP,’select rtrim(char_col),…….. from uc.test’);
或者
DBCC TRACEON (8765) WITH NO_INFOMSGS
1、在mysql建立表create table test(id varchar(10),name varchar(10)); insert into test values(‘1′,’zhang’); insert into test values(‘2′,’wang’); 2、在sql server 2008 建立對應的表,通過odbc 遠端同步資料 insert into test select * from OPENQUERY(MYSQLAPP,’select * from uc.test’); 或者直接 select * into test from OPENQUERY(MYSQLAPP,’select * from uc.test’); 也沒問題 如果是這樣varchar 型別,同步資料是沒有任何問題的。 但是如果換成char型別 1、在mysql建立表create table test(id char(10),name char(10)); 2、在sql server 2008 建立對應的表,通過odbc 遠端同步資料 insert into test select * from OPENQUERY(MYSQLAPP,’select * from uc.test’); 就要報錯了 連結伺服器 ‘MYSQLAPP’ 的 OLE DB 訪問介面 ‘MSDASQL’ 返回的資料與列 ‘[MSDASQL].id’ 所需的資料長度不匹配。所需的(最大)資料長度為 20,但返回的資料長度為 2。 |
写评论
很抱歉,必須登入網站才能發佈留言。