๐ Overview
Connecting Power BI to a SQL Server database allows analysts and decision-makers to transform raw relational data into interactive dashboards and reports. This integration is essential for real-time business intelligence.
In this article, you'll learn how to:
-
Configure SQL Server access
-
Connect using Power BI Desktop
-
Use DirectQuery or Import modes
-
Secure the connection
๐ ๏ธ Requirements
Before you begin, ensure the following:
-
โ
Power BI Desktop is installed
-
โ
SQL Server instance is running (local or remote)
-
โ
You have a database and user credentials
-
โ
Firewall and TCP/IP ports are open (usually port 1433 for SQL Server)
๐งญ Step-by-Step: Connect Power BI to SQL Server
๐ Step 1: Launch Power BI Desktop
Open Power BI Desktop and click "Get Data" from the Home ribbon.
๐๏ธ Step 2: Select SQL Server
-
In the Get Data window, choose SQL Server.
-
Click Connect.
๐ก You can also use the search bar in the Get Data window to find “SQL Server”.
๐ Step 3: Enter SQL Server Details
You'll see the SQL Server database connection dialog:
-
Server: localhost
, .\SQLEXPRESS
, or your remote server name
-
Database (optional): You can leave this blank to view all databases
Choose one of the data connectivity modes:
Click OK to proceed.
๐งพ Step 4: Authenticate
Choose your authentication method:
-
Windows (your current login)
-
Database (SQL login with username/password)
-
Microsoft account (if using Azure SQL)
Enter credentials and hit Connect.
๐ Step 5: Select Tables or Write a Query
You’ll now see the Navigator window with a list of available tables and views.
Click Load (for immediate import) or Transform Data to launch Power Query.
๐งน Step 6: Clean and Shape Data (Optional)
Inside Power Query Editor, you can:
-
Remove or rename columns
-
Filter rows
-
Merge/join tables
-
Change data types
Click Close & Apply when you're done.
๐ Import vs DirectQuery: What's the Difference?
Feature |
Import Mode |
DirectQuery Mode |
Speed |
Faster (local cache) |
Slower (live query) |
Data Size Limit |
Limited to memory |
Depends on SQL Server |
Refresh |
Manual or Scheduled |
Real-time or near real-time |
Use Case |
Small/medium datasets |
Large, changing datasets |
๐ Securing Your SQL Server Connection
-
Use parameterized queries or views to minimize risks
-
Apply row-level security (RLS) in Power BI
-
Limit database access by user roles
-
Avoid using sa
or admin-level accounts for Power BI
๐ค Publishing to Power BI Service
After building your report:
-
Click Publish from Power BI Desktop.
-
Choose your workspace.
-
In the Power BI Service, configure Gateway for on-prem SQL Servers.
๐ก๏ธ You'll need an on-premises data gateway to keep data synced and refreshed.
๐ง Final Tips
-
Use views or stored procedures for reusable logic
-
Use Power BI Parameters to switch between dev and prod environments
-
Keep data model lean for performance
โ
Summary
Connecting Power BI to SQL Server is a foundational skill for data analysts. It enables: