我想知道哪个版本的 SQL 基于连接字符串和任何其他方法在 c# 中连接我的应用程序。
基本上,用户在我的应用程序中提供连接字符串,它会连接到 Microsoft SQL Server 或 Microsoft Azure SQL。
因此,我想在相应版本上运行一组查询。
最佳答案
尽管 @@version
似乎是一种可行的方法,但解析这样的字符串可能会很棘手。 current documentation推荐这种方法:
SELECT SERVERPROPERTY('EngineEdition');
To programmatically determine the engine edition, use SELECT SERVERPROPERTY('EngineEdition'). This query will return '5' for standalone databases and '8' for managed instances in Azure SQL Database.
关于c# - 确定当前 SQL 版本是属于 Azure 还是独立的 Microsoft SQL Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53865786/