Bug #69523 Data Migration From SQL server failed
Submitted: 20 Jun 2013 11:40 Modified: 12 Feb 2016 8:54
Reporter: Petr Hybler Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: Migration Severity:S1 (Critical)
Version:MySQL Workbench 5.2 CE OS:Windows (Win Server 2003)
Assigned to: CPU Architecture:Any
Tags: failed, migration, sql server, workbench

[20 Jun 2013 11:40] Petr Hybler
Description:
Hello I have a problem with "migration tool" in MySQL Workbench ... I set up Source and Target and after that I am not able to "Retrive schema list from source" ... this is the log

*******************************************************************************/

Starting...
Connect to source DBMS...
- Connecting to source...
Connect to source DBMS done

Check target DBMS connection...
- Connecting to target...
Connecting to Mysql@localhost:3306...
Connecting to Mysql@localhost:3306...
Connected

Check target DBMS connection done

Retrieve schema list from source....
- Checking connection...
- Fetching catalog names...
Traceback (most recent call last):

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\db_mssql_grt.py", line 185, in getCatalogNames

    return [ row[0] for row in execute_query(connection, query) ]

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\db_mssql_grt.py", line 62, in execute_query

    return get_connection(connection_object).cursor().execute(query, *args, **kwargs)

pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'sp_databases'. (2812) (SQLExecDirectW)")

Traceback (most recent call last):

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\workbench\wizard_progress_page_widget.py", line 192, in thread_work

    self.func()

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\migration_source_selection.py", line 428, in task_fetch_schemata

    self.main.plan.migrationSource.doFetchSchemaNames(only_these_catalogs)

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\migration.py", line 221, in doFetchSchemaNames

    catalog_names = self.getCatalogNames()

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\migration.py", line 189, in getCatalogNames

    return self._rev_eng_module.getCatalogNames(self.connection)

SystemError: ProgrammingError("('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'sp_databases'. (2812) (SQLExecDirectW)")"): error calling Python module function DbMssqlRE.getCatalogNames

ERROR: Retrieve schema list from source: ProgrammingError("('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'sp_databases'. (2812) (SQLExecDirectW)")"): error calling Python module function DbMssqlRE.getCatalogNames

Failed

*******************************************************************************/

Can you help me please? I need to migrate SQL Server db to MySQL

How to repeat:
...
[20 Jun 2013 13:00] Alfredo Kojima
What version of SQL Server?
[21 Jun 2013 8:36] Petr Hybler
Hi, here is the version

$:> SELECT @@VERSION

> Microsoft SQL Azure (RTM) - 11.0.9041.138 
> May 23 2013 23:18:13 
> Copyright (c) Microsoft Corporation
[7 Aug 2013 0:52] Alfredo Kojima
Hi Peter,

SQL Server Azure is currently not supported. But if you're willing to spend some time, we can try getting it working.

First thing would be to add a workaround for this issue you're getting by opening the db_mssql_grt.py file and around line 185, where the sp_databases SP is executed, comment out the line that starts with return (by prepending it with a #) and replace it with something like:
return ["the_database_you_want_to_migrate"]

keep in mind indentation is important and must exactly match the existing return statement
[9 Aug 2013 12:35] MySQL Verification Team
Duplicate/related with this one: http://bugs.mysql.com/bug.php?id=69968 .
[14 Aug 2013 8:48] Dmitry Narizhnykh
As a workaround solution you can try the tool from http://convertdb.com/azure/mysql
[18 Jul 2014 13:19] Me Nno
As Alfredo Kojima mentioned, SQL Server Azure is currently not supported.

Problem with SQL Server Azure is that a couple of stored procedures are not available.

However, by changing a few lines in the "modules/db_mssql_grt.py" code you can make it work.

Here is the diff, as you can see the first change is, as Alfredo suggested, hardcoding the database name(s) you want to migrate.
The other two changes remove the extended_properties from the queries:

185,186c185
<     query = 'exec sys.sp_databases'
<     return [ row[0] for row in execute_query(connection, query) ]
---
>     return [ 'database1', 'database2', '...' ]
533,534c532,533
<         query_post_90 = """SELECT t.name, p.value
< FROM sys.tables t LEFT JOIN sys.extended_properties p ON p.major_id = t.object_id AND p.minor_id = 0 AND p.name = 'MS_Description' AND p.class_desc = 'OBJECT_OR_COLUMN'
---
>         query_post_90 = """SELECT t.name, ''
> FROM sys.tables t 
536a536
> 
586c586
<     sys.extended_properties.value as COLUMN_COMMENT
---
>     '' as COLUMN_COMMENT
589d588
<      LEFT JOIN sys.extended_properties ON sys.extended_properties.major_id = sys.columns.object_id and sys.extended_properties.minor_id = sys.columns.column_id and sys.extended_properties.name = 'MS_Description' and sys.extended_properties.class_desc = 'OBJECT_OR_COLUMN'
592a592
>
[11 Nov 2015 16:24] MySQL Verification Team
Are you tried the workaround mentioned in prior comments?. Try with new version 6.3.5. Thanks.
[12 Dec 2015 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[7 Jan 2016 3:38] Alessandro Correia
Just wanted to said that I have same problem as this issue. And I tried workaround of Alfredo Kojima and this worked.