How to test if database is hosted on SQL Azure?(如何测试数据库是否托管在 SQL Azure 上?)
问题描述
是否可以测试数据库是否托管在 SQL Azure 上?我正在查看 EF6 的 SqlAzureExecutionStrategy 并且只想在数据库实际上是 SQL Azure 数据库时应用.
Is it possible to test whether a database is hosted on SQL Azure? I am looking at SqlAzureExecutionStrategy for EF6 and only want to apply if the database is actually SQL Azure database.
目前我正在测试应用程序是否在 Azure 中运行.但是,我们正在考虑允许客户端自己托管 DB,因此希望通过某种方式来确定 DB 是 SQL Server 还是 Azure SQL.
Currently I am testing if App is running within Azure. However we are looking at allowing clients to host DB themselves so would like some way to identify if DB is a SQL Server or Azure SQL.
假设 EF 不知道,因为它隐藏了实现细节.
Assume EF won't know as it is hiding the implementation details.
我猜可能只是一个配置设置.只是想知道这在技术上是否可行.
Could just have a config setting I guess. Just wondered if it was technically possible.
推荐答案
于 2021 年 8 月更新以与更新的文档保持一致
SELECT CASE ServerProperty('EngineEdition')
WHEN 1 THEN 'Personal'
WHEN 2 THEN 'Standard'
WHEN 3 THEN 'Enterprise'
WHEN 4 THEN 'Express'
WHEN 5 THEN 'SQL Database'
WHEN 6 THEN 'Azure Synapse Analytics'
WHEN 8 THEN 'Azure SQL Managed Instance'
WHEN 9 THEN 'Azure SQL Edge'
WHEN 11 THEN 'Azure Synapse serverless SQL pool'
ELSE 'Unknown'
END
http://technet.microsoft.com/en-us/library/ms174396.aspx
这篇关于如何测试数据库是否托管在 SQL Azure 上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何测试数据库是否托管在 SQL Azure 上?
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
