以编程方式检测 SQL Server 版本 [英] Programmatically detect SQL Server Edition

查看:43
本文介绍了以编程方式检测 SQL Server 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 C# 与 SMO 结合使用,并尝试检测我要连接的 SQL Server 版本(例如,企业版、标准版).我知道如何获取版本信息,但这只能告诉我 SQL Server 的版本(例如,SQL Server 2008 与 SQL Server 2005).

I'm using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I'm connecting to. I know how to get the version information, but that only tells me what version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005).

有谁知道如何获取实际产品版本(例如企业版、标准版)?

Does anyone know how to get the actual product edition (e.g., enterprise, standard)?

我需要此信息,因为某些 SQL Server 功能仅适用于企业.因此,我可以尝试调用它们并捕获异常,但我更喜欢预先检测.

I need this information because some SQL Server features are only enterprise. Thus, I could just try to call them and catch the exception, but I'd much prefer an upfront detection.

谢谢!

推荐答案

看起来您可以通过 SMO 和 Server 对象来完成.有像 Information.Edition 这样的属性,看起来它应该做你想做的事.

It looks like you might be able to do it via SMO and the Server object. There are properties like Information.Edition which looks like it should do what you want.

这篇关于以编程方式检测 SQL Server 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆