Preamble
SQL Server has an interesting feature called Linked Servers. It is about linking other databases to SQL Server and using their data as local. There are many powerful open source systems written in PHP, and they mainly use MySQL as a database.
This blog post shows how to link a MySQL database to SQL Server and how to use a linked server in SQL queries.
What is a linked server?
A linked server in MSSQL is some other database server connected to this one, which allows querying and manipulating data in other databases. For example, we can link some MySQL database to MSSQL and use it almost like any other MSSQL database.
For more details, you can learn more about how to create a linked server (Linked Server) in Microsoft SQL Server.

Although communication with related servers is done through OLE DB vendors, there is also an OLE DB vendor for ODBC, and we can use it if there is no OLE DB vendor in our external database.
A linked server is available for the entire SQL Server instance. This means that all SQL Server databases can use a linked server to obtain data.
Linking MySQL to SQL Server
Adding a linked server and configuring connection parameters is not always easy and clear.
To bind MySQL to SQL Server, I had to create an ODBC DSN for MySQL (we called it MySQLCrm). Before proceeding to the next steps, make sure that the ODBC data source works.
Perform the following steps to associate MySQL with SQL Server:
- Run SQL Server Management Studio (SSMS)
- Connect to your server
- Expand the node Server objects from the tree to the left
- Right-click on related servers
- Select a new bound server
You should see the next dialog (or slightly different, but the idea remains the same).

Pay special attention to what you insert into this dialog. We have made the link work with this set of data. We tried different values, and if something is wrong by one millimeter, the connection is not established. This is a very damn sensitive dialog.
The connection string to a MySQL database should be like the one shown here:
DRIVER=(MySQL ODBC 8.0 Unicode Driver); SERVER=localhost; PORT=3306; DATABASE=crmlinked; USER=crmuser; PASSWORD=crm_user_password; OPTION=3;
Also pay attention to OPTION = 3 – without this we only get errors when connecting to the linked server.
Try saving by clicking OK and see if you can move to the linked server. If you receive errors, right click on the server and select the properties. Leaving the dialog open, go to the server options page. Set the RPC and RPC Out parameters to True.

We’re still not quite sure what these options do, but some of those who had trouble communicating with MySQL made it work after setting RPC to true.
For the query to really work, we need one more small change that affects the entire OLE DB vendor and therefore all the connections that use it. Open the “Vendors” node in the “Linked Servers” section, right-click MSDASQL (this is the OLE DB Vendor for ODBC data sources) and select the properties.

Select the check box only before Level Zero and click OK to save your changes.
Request data from a linked server
Querying related databases is really easy. Here is a table of clients from a crmlinked database in MySQL. This database is linked to my SQL Server.

The syntax of queries to the associated server is a bit different from what we normally write in SQL Server.
We need to use names from four parts: server.database.schema.table. Since there are no schemas in MySQL and the connection string contains the name of the database, we can leave them as shown here.
select * from MYSQLCRM...customers
Executing this request from SSMS gives the following conclusion. This is the same data as in MySQL client table.

Of course, we can also write more complex requests. All that ODBC can handle is good.
Mixing data from the local and associated server
The tables from the linked server are not completely isolated from the local database tables and views. We can also mix data from the local and linked servers.

To demonstrate a mixed query for local and linked tables, let’s write a simple query to get all clients from the local table and their credit ratings from the linked table.
SELECT
c.FirstName,
c.LastName,
crm_c.credit_rating as CreditRating
FROM
Customers c
LEFT JOIN MYSQLCRM...customers crm_c ON
c.ssn = crm_c.ssn
ORDER BY
crm_c.credit_rating,
c.LastName,
c.FirstName
Executing this query gives us the following conclusion.

Since Mark is not in the MySQL database (let’s say he’s a new customer in an online store and the sales department doesn’t have him in their CRM system yet), he doesn’t have a credit rating. In this case, John and Mary’s credit ratings are based on MySQL.
Using OPENQUERY() to execute a query on a linked server
In the above examples, all data processing is performed on SQL Server. This can be very suboptimal if there is a lot of data in the tables of linked servers. We may want – or usually want – to process some data on a linked server before SQL Server starts local processing. For this we have OPENQUERY().
Here is an example of using the OPENQUERY() function in a mixed query. We have to specify the name of the linked server and the SQL query to run on the linked server when OPENQUERY() is called. The red query is executed on a MySQL server and the results are read on SQL Server for further processing.
SELECT
c.FirstName,
c.LastName,
crm_c.credit_rating as CreditRating
FROM
Customers c
LEFT JOIN OPENQUERY(MYSQLCRM, '
SELECT
c.credit_rating
FROM
customers p
left join loyalty_points lp on
c.customer_id = lp.customer_id
WHERE
lp.points > 2500
') crm_c ON
c.ssn = crm_c.ssn
ORDER BY
crm_c.credit_rating,
c.LastName,
c.FirstName
OPENQUERY() is a great way to optimize and speed up mixed requests by executing more complex queries to related server data on the related server.
Finish
Linked Servers is a powerful SQL Server feature that makes it easy for us to use data from external servers. There are two ways to write queries using data from linked servers: direct queries, which perform all processing on SQL Server, and OPENQUERY(), which allows us to perform some processing on a remote server.
A linked server is an integration, so its use requires special care. Planning and performance measurement must be mandatory when planning the use of a linked server.
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
From Network Traffic to Cost Transparency: Enteros Approach to Amortized Cost Management in Telecom
- 12 February 2026
- Database Performance Management
Introduction Telecom operators today are no longer just connectivity providers. They are digital service platforms supporting 5G networks, IoT ecosystems, streaming services, cloud-native core systems, enterprise connectivity, and real-time analytics. Every call, message, streaming session, IoT signal, and digital interaction generates massive volumes of transactional and analytical data. That data is processed, stored, and monetized … Continue reading “From Network Traffic to Cost Transparency: Enteros Approach to Amortized Cost Management in Telecom”
From Transactions to Transparency: Enteros’ AI SQL Platform for Financial Database Performance and Cost Intelligence
Introduction In the financial sector, performance is not optional—it is existential. Banks, insurance providers, capital markets firms, fintech platforms, and payment processors operate in environments where milliseconds matter, compliance is mandatory, and financial transparency is critical. Every transaction—whether it’s a trade execution, loan approval, insurance claim, or digital payment—flows through complex database infrastructures. Yet as … Continue reading “From Transactions to Transparency: Enteros’ AI SQL Platform for Financial Database Performance and Cost Intelligence”
Driving Healthcare RevOps Efficiency with AI SQL–Powered Database Performance Management Software
- 11 February 2026
- Database Performance Management
Introduction Healthcare organizations today operate at the intersection of clinical excellence, regulatory compliance, and financial sustainability. Hospitals, health systems, payer organizations, and healthtech SaaS providers depend on digital platforms to manage electronic health records (EHRs), billing systems, revenue cycle management (RCM), patient portals, telehealth platforms, claims processing engines, and analytics tools. At the core of … Continue reading “Driving Healthcare RevOps Efficiency with AI SQL–Powered Database Performance Management Software”
Retail Revenue Meets Cloud Economics: Enteros AIOps-Driven Approach to Database Cost Attribution
Introduction Retail has become a real-time, data-driven industry. From omnichannel commerce and dynamic pricing engines to inventory optimization, loyalty platforms, recommendation systems, and last-mile logistics, modern retail runs on software—and software runs on databases. As retailers scale their digital presence, they increasingly rely on SaaS platforms, microservices architectures, hybrid cloud infrastructure, and distributed database environments. … Continue reading “Retail Revenue Meets Cloud Economics: Enteros AIOps-Driven Approach to Database Cost Attribution”