Detect whether a SQL Server instance runs on-premises or in a cloud platform such as Azure SQL or Amazon RDS.
Yes. SQL Server exposes edition and engine metadata you can query to confirm if the instance is Azure SQL Database, Azure SQL Managed Instance, Amazon RDS, or an on-prem install.
SERVERPROPERTY('EngineEdition') returns a numeric code. Values 5 and 8 indicate Azure SQL Database or Azure SQL Managed Instance. ‘RDS’ shows up in @@VERSION for Amazon RDS.
Run the syntax below in any database—even one with ecommerce tables like Customers or Orders—to get an immediate answer.
SELECT SERVERPROPERTY('EngineEdition') AS engine_edition,
SERVERPROPERTY('Edition') AS edition,
@@VERSION AS full_version;
1 = Enterprise/Standard/Developer (on-prem or IaaS VM). 5 = Azure SQL Database. 8 = Azure SQL Managed Instance. If @@VERSION contains “RDS”, the instance is Amazon RDS.
After confirming cloud status, you can safely run workload checks. Example: count unshipped Orders on an Azure SQL Database.
-- run only if EngineEdition = 5 (Azure SQL)
SELECT COUNT(*)
FROM Orders o
WHERE NOT EXISTS (
SELECT 1 FROM OrderItems i
WHERE i.order_id = o.id AND i.quantity > 0);
Always confirm hosting before using cloud-specific features like Automatic Tuning (Azure) or Multi-AZ failover (RDS). Log the EngineEdition value at app startup for diagnostics.
Ignoring version hints — Assuming on-prem because Edition = ‘Developer’. Always check EngineEdition and @@VERSION together.
Hard-coding feature logic — Branching on EngineEdition alone misses RDS VMs. Use both SERVERPROPERTY and @@VERSION for certainty.
Use Galaxy’s AI-powered SQL editor to store this detection query in a shared Collection so your team can reuse it without digging through Slack.
Yes. Google Cloud SQL adds “Cloud SQL” to @@VERSION. Combine that with EngineEdition = 3 to flag it.
No. Azure SQL Edge (container) reports EngineEdition = 8. Treat it as cloud-capable but not fully managed.
Negligible. SERVERPROPERTY and @@VERSION read cached metadata and execute in microseconds.