SQL Schema Discovery Report
Manually triggered flow that retrieves all tables in the FlowLibsDemoDB database and emails the list. Simple demo of the Get Tables action for schema introspection.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
FlowLibs - SQL Schema Discovery Report is a manually triggered flow that retrieves all tables exposed by a SQL Server connection and emails the complete list as a styled HTML report. It demonstrates the SQL Server connector's GetTables action for schema introspection — the simplest possible SQL Server flow and a great starting point for database-aware automation.
Use Case
IT admins and developers often need a quick inventory of tables available in a database — whether for onboarding, auditing, or building downstream automations. This flow provides a one-click schema discovery report delivered to email, without requiring direct database access or SSMS.
Flow Architecture
Manually trigger a flow
ButtonUser clicks "Run" in Power Automate to start the schema discovery report.
Init varSqlServerName
Initialize VariableReads the `flowlibs_SqlServerName` environment variable into a string variable. Runs in parallel with steps 2 and 3.
Init varSqlDatabaseName
Initialize VariableReads the `flowlibs_SqlDatabaseName` environment variable into a string variable. Runs in parallel with steps 1 and 3.
Init varNotificationEmail
Initialize VariableReads the `flowlibs_NotificationEmail` environment variable into a string variable. Runs in parallel with steps 1 and 2.
Get SQL Tables
SQL Server — GetTablesRetrieves all tables exposed by the SQL Server connection.
Select Table Names
Select (Data Operation)Maps each table to a `TableName` / `FullName` pair. Runs in parallel with step 6.
Init varTableCount
Initialize VariableCounts total tables returned using `length()`. Runs in parallel with step 5.
Compose HTML Table Rows
Select (Data Operation)Generates an HTML `<tr>` row for each table.
Compose Full HTML Report
ComposeAssembles the complete HTML email body with header, metadata, and table.
Send Schema Report Email
Outlook — SendEmailV2Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SqlServerName | String | your-server.database.windows.net | SQL Server hostname (used in the email report header). |
| flowlibs_SqlDatabaseName | String | FlowLibsDemoDB | Database name (used in the email report header and subject line). |
| flowlibs_NotificationEmail | String | admin@your-tenant.onmicrosoft.com | Recipient email address for the schema report. Set to the mailbox that should receive the schema inventory. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SQL Server | shared_sql | GetTables (retrieves all tables from the connected database) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (sends the schema report email) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Change the target database
- Update the SQL Server connection to point to your server/database. The flowlibs_SqlServerName and flowlibs_SqlDatabaseName env vars update the report header — the actual database connection is managed by the SQL Server connector's connection configuration.
- Change the recipient
- Update the flowlibs_NotificationEmail environment variable value to the mailbox that should receive the schema inventory.
- Add column details
- After Get SQL Tables, add a GetTable (metadata) action inside an Apply to Each loop to retrieve column definitions for each table.
- Schedule the report
- Replace the manual trigger with a Recurrence trigger for weekly or monthly schema audits.
- Post to Teams instead
- Replace SendEmailV2 with PostMessageToConversation to deliver the report to a Teams channel.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Table count
Counts the tables returned by the SQL Server GetTables action and stores the result in varTableCount.
EXPR.02HTML row generation (Select)
Select action map expression that emits one HTML table row per table returned by GetTables.
EXPR.03String assembly for HTML report
Uses concat() with replace() to unwrap the Select action's JSON array into a clean HTML table string.
EXPR.04Email subject with dynamic count
Builds the dynamic email subject line including the database name and total table count.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.