I'm trying to migrate few tables from SQL Server to MySQL using MySQL Workbench migration wizard. All work fine for structure migrations but when I go to the data migration section it throws an error for one table:
ERROR:
dbo
.Documents
:SQLExecDirect(SELECT [DocumentID], [CategoryID], CAST([DocumentName] as NVARCHAR(255)) as [DocumentName], [Active], [NavigatorID], CAST([DocumentText] as NTEXT) as [DocumentText], [UseSubtitle], CAST([DocumentSubtitle] as NVARCHAR(255)) as [DocumentSubtitle], CAST([DocumentPlainText] as NTEXT) as [DocumentPlainText], [DocumentType], CAST([DocumentLink] as NVARCHAR(255)) as [DocumentLink], [Sitemap], CAST([SubtitleImage] as NVARCHAR(255)) as [SubtitleImage], CAST([MetaTags] as NVARCHAR(8000)) as [MetaTags], CAST([MetaDescription] as NVARCHAR(8000)) as [MetaDescription], [AccessLevel] FROM [ctool_test].[dbo].[Documents]): 42000:1131:[Microsoft][ODBC SQL Server Driver][SQL Server]The size (8000) given to the convert specification 'nvarchar' exceeds the maximum allowed for any data type (4000).2131:[Microsoft][ODBC SQL Server Driver][SQL Server]The size (8000) given to the convert specification 'nvarchar' exceeds the maximum allowed for any data type (4000).
Based on that what I can understand it limits columns with nvarchar
data to max size of 4000 when MySQL can handle 65535.
Any clue how I can get this to work?
Thanks
-
What are the source columns (NVARCHAR(4000) or NVARCHAR(MAX))? How are you building that SELECT statement?Aaron Bertrand– Aaron Bertrand2013年08月22日 19:29:31 +00:00Commented Aug 22, 2013 at 19:29
-
Source column has text data and is set as NVARCHAR(8000). Select statement is done by MySQL Workbench so I even don't need to touch queries (but I can save them for command line execution if needed)JackTheKnife– JackTheKnife2013年08月22日 19:36:51 +00:00Commented Aug 22, 2013 at 19:36
-
There is no such thing as NVARCHAR(8000). Where are you seeing this?Aaron Bertrand– Aaron Bertrand2013年08月22日 19:38:38 +00:00Commented Aug 22, 2013 at 19:38
-
Through MySQL Workbench migration wizard - Create Schemata step.JackTheKnife– JackTheKnife2013年08月22日 19:43:54 +00:00Commented Aug 22, 2013 at 19:43
-
Well MySQL Workbench does not have a very good grasp of SQL Server data types.Aaron Bertrand– Aaron Bertrand2013年08月22日 19:44:36 +00:00Commented Aug 22, 2013 at 19:44
1 Answer 1
Well, since you have data currently stored in SQL Server, and it's already in an NVARCHAR
column, then either it's an NVARCHAR <= 4000
(in which case you can't lose any data, and should just change all instances of NVARCHAR(8000)
to NVARCHAR(4000)
), or it's an NVARCHAR(MAX)
column, in which case you change all instances of NVARCHAR(8000)
to NVARCHAR(MAX)
. Or just leave out those CASTs
- do you really need them?
As an aside, you should probably change as NTEXT
to as NVARCHAR(MAX)
as well.
-
OK, got this to work following all answers above.JackTheKnife– JackTheKnife2013年08月22日 19:56:34 +00:00Commented Aug 22, 2013 at 19:56
Explore related questions
See similar questions with these tags.