Stored Procedure Call from SQL Server to MYSQL over Linked Server - mysql

I am currently trying to build a process for checking SQL and MYSQL databases and am almost there thanks to the much help I have received on here. My last issue and I am hoping that its an easy one is the following. I have a SQL Server 2014 installation talking to a MYSQL database over a linked server. I am able to run a select over the linked server without any issue now but when I run a stored procedure passing in some date variables I get the following error
Msg 7399, Level 16, State 1, Line 22
The OLE DB provider "MSDASQL" for linked server "TESTCONNECTION" reported an error. The provider did not give any information about the error.
Msg 7350, Level 16, State 2, Line 22
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "TESTCONNECTION".
The Code I am running is
SELECT * FROM OPENQUERY ( TESTCONNECTION,'CALL
usp_sync_check_3(''2016-11-13'',''2016-11-15'');' )
Am I not calling the stored procedure correction, when I run it from MySQL everything works fine, can anyone offer any suggestions. I have been googling but nothing that seems to fix my issue.
Thanks P

I have now figured this out, I was not passing in the schema name as well for the stored procedure, once I had done this everything worked as it should. Thanks PJD

Related

Attempting to retrieve data from linked server - Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060"

I have an application which connects and stores data on a MySQL database, I need to connect and retrieve this data in a view from another application which uses an SQL Server Database. My attempt to handle this was to create a linked server that connects to the MySQL Server in SQL Server.
That seems to have worked, all connections have passed and if I run the following queries
SELECT * FROM MYSQLLINK...table1` or `SELECT * FROM OPENQUERY(MYSQLLINK, 'SELECT * FROM table1')
I get results.
Problem
The problem is, I want to create a view which joins quite a few reference tables ( I actually have 20 joins but it's joining the same table because it's a big reference table.)
but on execution on the SELECT or CREATE VIEW I get the following error.
OLE DB provider "MSDASQL" for linked server "MYSQLLINK" returned
message "[MySQL][ODBC 5.1 Driver]Lost connection to MySQL server at
'waiting for initial communication packet', system error: 10060".
Msg 7303, Level 16, State 1, Line 4
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQLLINK".
Completion time: 2020-01-19T22:00:00.1759949-04:00
I am unsure why this is occurring, would appreciate if any could assist in figuring this out and helping in mitigating this error that will allow my view to be created and queried.
I've noticed if I comment out 85% of the joins the query does not fail. Where would I increase this time out the tome that is mentioned?
I should also mention that the MySQL is on an AWS server while the SQL Server is on my localhost.
I couldn't recreate the failure test case on my local-end, but what you mentioned directs us to following pointers:
Your linked server connection is getting timeout (probably)
Potential reason for timeout could be the high response time of query (view which joins quite a few reference tables)
What about changing the approach:
Can you create the view on MySQL rather than on SQL Server?
Is materialization of the result of the view is an option?
Or alternatively, what about writing a stored procedure on SQL Server-end and sequentially join your tables one-at-a-time (or as-many-reasonable-at-a-time) with use of temporary tables to store intermediate results?

Linked server requires no encryption

I'm trying to replicate a Linked Server from a Windows 2k3 / SQL Server 2000 to a Windows 2008 / SQL 2008 R2 setup.
The SQL 2000 Linked server is setup like this:
srvname=blah.blah.com
srvproduct=SQL Server
providername=SQLOLEDB
datasource=blah.blah.com
srvnetname=blah.blah.com
rpc=1
rpcout=1
dataaccess=1
The SQL 2008 R2 Linked Server is setup the same way.
I've copied the remote users, and all seems fine, except when i tried to connect, I get this error:
OLE DB provider "SQLNCLI10" for linked server "blah.blah.com" returned message "Client unable to establish connection". (Microsoft SQL Server, Error: 20)
Encryption not supported on SQL Server
I still have access to the SQL 2000 machine, and can run the query fine. I'm guessing the issue is that Windows2008 machine is trying to send data encrypted, but the linked server is saying it can't handle encryption. Something along those lines. I've played with various different Data Source types, and nothing seems to pan out. I don't have access to the remote server so I don't know what OS/Database is on it.
Anyone with more SQL knowledge than me can point me in the right direction?
Thanks!
Hooray! I've done it. For anyone that may find this issue in the future, this is what I did:
Create ODBC connection to SOMESERVER.COM, call it dsnSOME
Driver: SQL Server
Name: dsnSOM
Server: SOMESERVER.COM
Create a Linked Server to dsnSOM:
Linked server: "SOMESERVER" (I don't think it matters)
Provider: Microsoft OLE DB Provider for ODBC Drivers
Product Name: dsnSOME
Data source: dsnSOME
And that's it. Now when I call the stored procedure I call:
[SOMESERVER].database.owner.storedprocedure
And it works!
It seems that for whatever reason, when trying to run a stored procedure on SQL 64 bit to a SQL 32 bit linked server directly, it gives this weird message about Encryption. However going through the ODBC and it works great.

Trying to migrate SQL Server to MySQL using MySQL Workbench. Error: "[Microsoft][ODBC Driver Manager] Invalid argument value" when migrating data

Long time lurker, first time poster; hoping anyone can help me out.
Im using MySQL Workbench 5.2.41 to migrate a database from SQL Server to MySQL 5.0.8
The entire process goes smoothly: both SQL and MySQL connection Tests are good, the skemea and table create as expected, everything checks out until the 'Bulk Data Transfer' step. At that point I receive this error:
...
Migrating data...
wbcopytables.exe --odbc-source=DSN=SQL Server 11;DATABASE=;UID=sa --target=root#127.0.0.1:3306 --progress --passwords-from-stdin --thread-count=1 --table [GSAClosers_v2] [dbo].[AccountBase] `dbo` `AccountBase`
`dbo`.`AccountBase`:Copying 84 columns of 169530 rows from table [GSAClosers_v2].[dbo].[AccountBase]
ERROR: `dbo`.`AccountBase`:SQLGetData: HY009:10:[Microsoft][ODBC Driver Manager] Invalid argument value `dbo`.`AccountBase`:
Finished copying 0 rows in 0m00s
Copy helper has finished
...
For connectors I'm using Microsoft SQL Server / ODBC Data Source / DSN: SQL Server and for MySQL the IP and port(3306).
SQL Server 2012 Management Studio connects and all operations work as expected.
O, side not: both are on the same localhost machine.
If anyone can shed some light on this I would be forever indebted. Thanks in advance
From here:
[Microsoft][ODBC Driver Manager] Invalid argument value.
Regarding to the error message and code you provided, which seems is
database is invalid or cannot be accessed. That means either the
database does not exist or the user does not have permission to access
the database.
It turns out you need specify the instance after the server name, so
in the server name in the dialog box for creating the ODBC Data
Source, you must enter it as either: MyServer\SQLEXPRESS or
.\SQLEXPRESS
I think you may have a problem connecting to your database from wbcopytables.exe. Keep in mind that this is a separate tool so the fact that you can connect from the rest of the Migration Wizard doesn't imply that you will connect in wbcopytables.exe.
The thing that worries me the most is that your DSN has whitespace characters. This might be interpreted by the Windows terminal as independent command line parameters. One thing you can do is to edit your DSN name removing the whitespaces and try again.
You may also want to connect without a DSN by putting all your connection parameters explicitely as explained in my blog post: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
And, by the way, since MySQL Workbench 5.2.42 is out you should go and get it. The Migration Wizard is pretty new so important bug fixes are likely launched in each recent Workbench release.
In either case I think you should file a bug with your issues with a detailed explanation about how to reproduce it, possible solutions, etc.
Hope this helps.
Ok, got it figured out: un-install java. install java 1.6, use MySQL Migration Tool. change all data types to varchar, ints and bits. run migrations....eat data.

Issue calling a stored procedure with one input parameter on a linked server on my local SQL Server

I am setting up a SQL Server database and have been given access to call a stored procedure in a remote server to help populate some tables.
I created a linked server as SSIS in Visual Studio 2008 and SQL Server Management Studio 2008 seem to not like EXEC statements in their SSIS packages for remote servers.
So having successfully set up linked server I try to execute my stored procedure with the following
Select * from OPENQUERY(LinkedServerName, 'exec storedProc paramValue')
But get the following error
Msg 208, Level 16, State 1, Procedure storedProc, Line 49
Invalid object name '#tmp_bl'.
I have tried to Select my Linked server but no luck.
Does anyone know what the exec statement should be so I can put it into a local SSIS package?
Msg 208, Level 16, State 1, Procedure storedProc,
Line 49 Invalid object name '#tmp_bl'.
Looks like the SP you are calling, in turn tries to access a temp table named #tmp_bl.
So, when you try to run your SSIS package from design (BIDS) it validates the package and couldn't found temp table; so errors.
Solution: Create the temp table first (using SSMS/Sqlcmd) and then try to run the package; like
create table #tmp_tbl ....
If you are trying to run the package from command prompt using dtexec utility then make the delayvalidation property of the package control (control which actually executing your temp table; either DataFlow task or SQLTask) to True (DelayValidation = True). Which, will not validate to see whether temp table exist or not while validating your entire package.

SQL Server 2008 linked MySQL server slow

Running MSSQL Server 2008 Standard SP 2 64-bit on Win2K8. I have installed on this server the 64-bit MySQL ODBC driver version 5.1.8 from 10/28/2010. I have configured a DSN linking to a MySQL server 5.1 running on a Mac apple-darwin9.8.0 server (don't ask me, I inherited this). I have successfully created a linked server via MDSASQL to a specific MySQL database.
From the SQL Server box I can run simple queries of the nature
SELECT * FROM mysql_table WHERE id = 1;
However, it is painfully slow. A query as above takes 19 minutes and 52 seconds to execute; the same query takes 0.04 seconds when executed locally.
Further, I attempted to execute a simple update of the nature
UPDATE mysql_table SET field = 0 WHERE id = 1;
This ran for 2 hours before returning the following error:
OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" returned message "Out of memory.".
Msg 7399, Level 16, State 1, Line 3
The OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL" reported an error. The provider ran out of memory.
Msg 7330, Level 16, State 2, Line 3
Cannot fetch a row from OLE DB provider "MSDASQL" for linked server "LINKED_MYSQL".
This comes on the heels of several failed jobs involving updates to the same table, all of which fail approximately two hours after they commence.
I have checked the permissions on the mysql and the user specified in the DSN has the appropriate permissions (well, all permissions) in mysql.user.
I would be most appreciative if anyone could give me any avenues to investigate to get this working.
Avoid joins to linked server tables and have a look at dynamic openqueries
And refer to this question that posted ealier.
Linked Server Performance and options