Get current username in Power Query via LocalDB or SQL Server
✓ Published0🌍 Public
HHugoberry
Last edited Apr 2, 2017
Created on Apr 1, 2017
This example shows three Power Query functions that retrieve the current username from a SQL Server environment using the `SYSTEM_USER` SQL function. It demonstrates how to query a local SQL Server instance, a LocalDB instance from SQL Server 2016 Express, and a legacy LocalDB v11.0 instance. The code uses the `Sql.Database` API from Power Query’s standard library, passing server names and a query option to execute the `SELECT` statement. Each function returns the username as a single value, illustrating the connection-string differences between LocalDB versions and a default local instance.
AI-generated description