4. Connecting to Databases: SQL Server, MySQL, DirectQuery and Live Connection
4.2 Connecting to Microsoft SQL Server
Steps in Power BI
- Home › Get data › SQL Server (or Get data › More… › Database › SQL Server database › Connect).
- Server:
QCSERVER01(for a named instance useQCSERVER01\SQLEXPRESS; for a specific port useQCSERVER01,1433). - Database (optional):
QuickCommerceDB. If you fill it in, the Navigator opens directly at this database. - Data Connectivity mode: Import (recommended to start) or DirectQuery (see 4.6).
- Leave Advanced options closed for now. They are covered in 4.3.
- Click OK. In the credentials window, choose a tab on the left:
- Windows – Use my current credentials (your Windows login) or Use alternate credentials.
- Database – a SQL Server login, e.g. user
pbi_readerand its password. - Microsoft account – for Azure SQL with Microsoft Entra ID (formerly Azure Active Directory).
- Select the level these settings apply to (the server, or server + database) › Connect. If you see an encryption warning, speak to your database admin. Do not simply accept an unencrypted connection for sensitive data.
- In the Navigator, tick
Orders,DarkStore,Product,Customer,DeliveryPartner. The Select Related Tables button ticks tables linked by foreign keys automatically. - Click Transform Data (not Load) so you can remove columns you do not need, rename columns and set types.
let
Source = Sql.Database("QCSERVER01", "QuickCommerceDB"),
Orders = Source{[Schema = "dbo", Item = "Orders"]}[Data],
Kept = Table.SelectColumns(Orders, {"OrderID", "OrderDateTime", "CustomerID", "StoreID",
"ProductID", "Quantity", "Amount", "Discount", "DeliveryFee", "DeliveryTimeMins",
"OrderStatus", "PaymentMode", "Platform"}),
Recent = Table.SelectRows(Kept, each [OrderDateTime] >= #datetime(2025, 1, 1, 0, 0, 0))
in
Recent
Ask for a read-only login and a view
He bagha: ask the database team for a read-only user and, ideally, a view that already joins and filters what you need (for example vw_MaharashtraOrders). Views are easy to reuse and keep query folding working.
Practice task
Install SQL Server Express (free) on your laptop, restore or create a small QuickCommerceDB with Orders and DarkStore, and connect in Import mode with Windows authentication. Load fakt the columns listed above.
Ravindra Bagale's Tip
A common mistake is ticking every table in the Navigator "just in case". Select only the tables and views you need and remove unused columns early. Importing a 40-column table when you need 8 makes refresh slow and the model heavy. Don't worry – after doing it two or three times, it becomes a habit.
Ravindra Bagale's Tip – मराठी
एक common चूक म्हणजे Navigator मध्ये "कदाचित लागेल" म्हणून प्रत्येक table tick करणं. फक्त लागणारे tables आणि views निवडा आणि न वापरलेले columns लवकर काढा. 8 columns लागत असताना 40 columns चा table import केला तर refresh slow होतो आणि model जड होतं. घाबरू नका, दोन-तीन वेळा केलं की सवय होते.
Ravindra Bagale's Tip – हिंदी
एक common गलती है Navigator में "शायद काम आए" सोचकर हर table tick कर देना. सिर्फ़ ज़रूरी tables और views चुनो और बेकार columns जल्दी हटा दो. 8 columns चाहिए और 40 columns की table import की, तो refresh slow होता है और model भारी हो जाता है. घबराओ मत, दो-तीन बार करने पर आदत हो जाती है.