If you’re a DBA, developer, or IT lead tired of missing key SQL Server issues — you’re not alone. Fortunately, it’s easy to pipe alerts directly into a Microsoft Teams channel in real time.
Here’s a step-by-step guide showing two ways to do it:
- ✅ Using Power Automate
- ✅ Or a simpler method using Teams’ built-in channel email
🛠️ Step 1: Enable and Configure Database Mail
First, make sure Database Mail is enabled on your SQL Server.
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Database Mail XPs', 1;
RECONFIGURE;
Then go to SSMS → Management → Database Mail, and create a new mail profile with your SMTP info.
🔔 Step 2: Create a SQL Alert Script
Here’s a basic example that checks for over 100 pending orders and sends an alert:
DECLARE @count INT;
SELECT @count = COUNT(*) FROM dbo.Orders WHERE Status = 'Pending';
IF @count > 100
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DBA_Alerts',
@recipients = 'your_email@example.com',
@subject = '🚨 High Pending Orders',
@body = 'There are more than 100 pending orders in the system.';
END
You can adapt this logic for any metric or threshold that matters to your team.
🔄 Option 1: Send SQL Alerts to Microsoft Teams with Power Automate
Want more control and richer notifications? Power Automate is your friend.
🔧 How to Set It Up:
- Go to Power Automate
- Create an Automated Cloud Flow
- Trigger:
When a new email arrives (V3) - Add a condition: Filter by subject line (e.g., contains “High Pending Orders”)
- Action:
Post a message in a Teams channel - Choose your Team and Channel → Format the message
- Save & test
That’s it — your SQL alerts are now flowing into Teams with full control and flexibility.
✉️ Option 2: Send Directly to a Teams Channel via Email (No Power Automate)
Don’t want to mess with Power Automate? No problem.
Microsoft Teams channels have hidden email addresses you can send to directly.
📨 Here’s how:
- In Teams, go to the channel you want to alert (like
#sql-alerts) - Click the three dots > select “Get email address”
- Copy that email (looks like
alerts@groupname.teams.ms) - Update your SQL script to send directly to it:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'DBA_Alerts',
@recipients = 'yourchannel@domain.teams.ms',
@subject = '🚨 SQL Alert: High Pending Orders',
@body = 'There are more than 100 pending orders in the database as of '
+ CONVERT(VARCHAR, GETDATE(), 120);
No additional tools or licenses required — and it shows up directly in the channel.
🆚 Power Automate vs Direct Email — Which Should You Use?
| Feature | Power Automate | Teams Email |
|---|---|---|
| Setup Complexity | Moderate | Very Easy |
| Custom Logic & Routing | ✅ Yes | ❌ Limited |
| Cost | Free tier (but M365 needed) | Free |
| Good For | Advanced use cases | Fast setup or prototyping |
✅ Wrap-Up
With either method, your SQL Server can alert your team to problems in real time — no more digging through logs or missed issues.
Use this system to notify your team about:
- ⚠️ Blocking sessions
- ⌛ Long-running queries
- 💾 Backup failures
- 📊 Custom metric thresholds
All without ever leaving SSMS.
Discover more from SQLYARD
Subscribe to get the latest posts sent to your email.


