It is possible to connect to many data sources using Power Query (more in this article) and SQL Server database is one of them. This article will tell you how to set connection to SQL Server table directly from Excel in few simple steps.

Guide to Data Import and Connecting to SQL Server from Excel via Power Query

It is not needed to use Power Query to establish a connection with SQL Server although it is the most comfortable way. This way to import data can be found in article How to execute SQL query in Excel. But back to our topic.

We will import prepared view to SQL Server instance localhost\MOJEINSTANCE in database Temp. The view is named udv_SalesByProducts and it displays sales by product with time context. This view is needed to be imported into Excel together with connection to database so that we will be able to refresh the data in Excel whenever we want to.

In case you do not know where is your SQL server located or you do not hold access rights, let your IT admin help you.

Step 1) Select Power Query card in Excel – from database – from SQL Server database

Step 2) Fill in name of the server and database in which is the view located. You have an option to set SQL query to perform on the server. We will leave the field for the SQL command empty since object (view) is needed to be displayed.

Napojení na SQL Server

Step 3) In the last step, all that’s left to do is select object and confirm via load button. We also have an opportunity to edit data further and create steps continuity using Power query editor. These steps would perform after every update.

The table has been created on the newly created list. It contains data from SQL Server and it is possible to update it as you wish.

Rate this post
Tags:

Jan Zedníček - Data & Finance

My name is Jan Zedníček and I work as a freelancer. I have been working as a freelancer for many companies for more than 10 years.
I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym and I enjoy tasting of best quality rums.
I am trying to summarize all my knowledge on this website not to forget them and to put them forward to anyone.

Leave a Reply

Your email address will not be published. Required fields are marked *