Question : Migrating date from MySQL to MSSQL run time error issue

Hi,
I am trying to migrate data from a table in MySQL to MSSQL.
I have been using SSIS Packages in Microsoft Visual Studio to help me do this but i have come across a problem. When pulling the informaion from the MySQL database i get a run time error.
This is the code i have been using:

TRUNCATE TABLE [DataView].[dbo].[CUSTOMER_HISTORY_TEMP];

GO

BEGIN

DECLARE @max_time VARCHAR(255), @remote_query VARCHAR(255)

SELECT @max_time = CONVERT(varchar,ISNULL(MAX(dw_timestamp),CAST('1990-01-01' AS DATETIME)),120)
FROM [DataWarehouse].[dbo].[CUSTOMER_HISTORY];

SET @remote_query = 'SELECT * FROM CUSTOMER_HISTORY WHERE dw_timestamp>="' + @max_time + '" ORDER BY history_id limit '

DECLARE @record_count INT, @while_counter INT, @limit_start INT, @limit_amount INT

SET @limit_start=0
SET @limit_amount=1000
SET @while_counter=-1

SELECT @record_count=count(*) FROM [DataView].[dbo].[CUSTOMER_HISTORY_TEMP]

WHILE @while_counter<@record_count
            BEGIN
                        DECLARE @final_query VARCHAR(255)
                        SET @final_query = @remote_query + CAST(@limit_start AS VARCHAR) + ',' + CAST(@limit_amount AS VARCHAR)
                        INSERT INTO [DataView].[dbo].[CUSTOMER_HISTORY_TEMP]
                        EXEC('SELECT * FROM OPENQUERY(IBBINTRAISP_LOCAL,''' + @final_query + ''') AS subq');
                        SET @while_counter=@record_count
                        SELECT @record_count=count(*) FROM [DataView].[dbo].[CUSTOMER_HISTORY_TEMP]
                        SET @limit_start= @limit_start + @limit_amount
            END
END

--This is the Error i am recieveing when i run this:
OLE DB provider "MSDASQL" for linked server "IBBINTRAISP_LOCAL" returned message "Requested conversion is not supported.".
Msg 7341, Level 16, State 2, Line 1
Cannot get the current row value of column "[MSDASQL].history_text" from OLE DB provider "MSDASQL" for linked server "IBBINTRAISP_LOCAL".

Any thought would be appriciated,
Thank you.



Answer : Migrating date from MySQL to MSSQL run time error issue

Hi,

This looks like you have a data casting problem. Certain field datatypes will need special handling. See this page for more info:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=304025&SiteID=1

Regards,

Lee
Random Solutions  
 
programming4us programming4us