How to Connect to SQL Server in Power BI: Step-by-Step Guide
To connect Power BI to SQL Server, open Power BI Desktop, click
Get Data, select SQL Server, then enter your server name and database. Choose the connection type (Import or DirectQuery), provide credentials if needed, and load your data to start building reports.Syntax
When connecting Power BI to SQL Server, you use the Get Data feature with these key inputs:
Server: The name or IP address of your SQL Server instance.Database: The specific database you want to connect to (optional).Data Connectivity Mode: Choose Import to load data into Power BI or DirectQuery to query data live.Authentication: Provide Windows or SQL Server credentials to access the database.
power_bi
Get Data > SQL Server > Server: "your_server_name" > Database: "your_database_name" > Data Connectivity Mode: Import or DirectQuery > Credentials
Example
This example shows how to connect Power BI Desktop to a SQL Server named SQLSERVER01 and database SalesDB using Import mode.
text
1. Open Power BI Desktop. 2. Click on "Get Data" > "SQL Server". 3. In the "SQL Server database" window, enter: - Server: SQLSERVER01 - Database: SalesDB 4. Select "Import" as the data connectivity mode. 5. Click "OK". 6. Enter your credentials if prompted. 7. Select tables or write a query to load data. 8. Click "Load" to import data into Power BI.
Output
Power BI loads the selected tables from SalesDB into the data model, ready for report creation.
Common Pitfalls
Common mistakes when connecting Power BI to SQL Server include:
- Using incorrect server or database names causing connection failures.
- Choosing the wrong authentication method or missing credentials.
- Confusing Import mode with DirectQuery, which affects data refresh and performance.
- Firewall or network settings blocking access to the SQL Server.
Always verify server accessibility and credentials before connecting.
text
Wrong way: Get Data > SQL Server > Server: "wrong_server" Right way: Get Data > SQL Server > Server: "correct_server" Provide valid credentials
Quick Reference
| Step | Action | Notes |
|---|---|---|
| 1 | Open Power BI Desktop | Start your report creation |
| 2 | Click Get Data > SQL Server | Choose SQL Server connector |
| 3 | Enter Server and Database | Use correct names or IPs |
| 4 | Select Import or DirectQuery | Import loads data; DirectQuery queries live |
| 5 | Provide Credentials | Windows or SQL Server authentication |
| 6 | Select Tables or Write Query | Choose data to load |
| 7 | Click Load | Data loads into Power BI model |
Key Takeaways
Use the Get Data > SQL Server option in Power BI Desktop to start your connection.
Enter the correct server and database names to avoid connection errors.
Choose Import mode to load data or DirectQuery for live queries depending on your needs.
Provide valid credentials matching your SQL Server authentication method.
Check network and firewall settings if you cannot connect to the server.