Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT * FROM MySQL Linked Server using SQL Server without OpenQuery

Tags:

I am trying to query a MySQL linked server using SQL Server.

The below query runs just fine.

SELECT * FROM OPENQUERY([Linked_Server], 'SELECT * FROM Table_Name')

Is it possible to run the same query without using the OpenQuery call?

like image 479
Kevin Avatar asked Aug 12 '15 14:08

Kevin


People also ask

How do I select data from a linked server in SQL?

1 Open SQL Server Management Studio, navigate to the Object Explorer pane, and select Server Objects > Linked servers > Providers. 2 Right-click mrOledb. Provider and select Properties. 3 Select allow in process, and then click OK.

How do I access a linked server in SQL?

Open SQL Server Management Studio and connect to an instance of SQL Server. In the Object Explorer, expand the node for the SQL Server database. In the Server Objects node, right-click Linked Servers and click New Linked Server. The New Linked Server dialog is displayed.

Why is Openquery faster?

The OPENQUERY is faster than the linked server because when we use the linked server, the SQL Server breaks the query into local and remote queries. The local queries are executed on the local server, and remote queries will be sent to the remote server.


2 Answers

Found the answer here. Now I can the three dot notation query. Thanks

http://www.sparkalyn.com/2008/12/invalid-schema-error/

Go to the provider options screenIn SQL Server 2005 you can see the list of providers in a folder above the linked server (assuming you have appropriate permissions). Right click on MSDASQL and go to properties. In SQL Server 2000, the provider options button is in the dialog box where you create the linked server. Check the box that says “level zero only”

like image 107
Kevin Avatar answered Oct 18 '22 17:10

Kevin


you can use the statement below

select * from [linkedServerName]...[databaseName.TableName]

but before executing the code above ,, you have to do some changes ..

In the SSMS

SSMS -> Expand "linked servers" Folder -> open Provider folder -> find MSDASQL and gets it's property

Then check "Level Zero Only" press Ok

Then execute the above query and Enjoy it !!!

like image 39
vahid basirat Avatar answered Oct 18 '22 19:10

vahid basirat