开发者

Inserting MS-SQL server Text type into MySQL server

开发者 https://www.devze.com 2023-04-04 00:02 出处:网络
I have a SQL 2008 R2 server linked with a MySQL 5.5 server. When I try to insert a Text column from the SQL server into a Text column in the MySQL server it fails.

I have a SQL 2008 R2 server linked with a MySQL 5.5 server. When I try to insert a Text column from the SQL server into a Text column in the MySQL server it fails. Query -

INSERT INTO OPENQUERY(MYSQL, 'SELECT bio FROM d.test')
SELECT bio FROM test.dbo.ARTIST
where art_no = 3

the bio column in the SQL Server is type text - SQL_Latin_General开发者_JS百科_CP1_CI_AS and the bio column in the MySQL server is type text - charater set Latin1 collate - latin1_general_ci

The errors I get are:

Msg 7399, Level 16, State 1, Line 12

The OLE DB provider "MSDASQL" for linked server "MYSQL" reported an error. The provider did not give any information about the error.

Msg 7343, Level 16, State 2, Line 12

The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]". Unknown provider error.


The TEXT data type in MS SQL is an odd / "second class" creature. Any chance you could convert the column to nvarchar(max)? If so, it's possible that might resolve your linked server issue. The T-SQL to change the column type looks like this:

ALTER TABLE [YourTableName] ALTER COLUMN [YourColumnName] nvarchar(max)


Try this as a workaround:

 INSERT INTO OPENQUERY(MYSQL, 'SELECT bio FROM d.test')
       SELECT CAST(bio as varchar(max))
       FROM test.dbo.ARTIST
       where art_no = 3
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号