Permalink
Browse files

Fix Machine Type issue on old sql version

  • Loading branch information...
gboge committed Jul 4, 2017
1 parent 0425d4b commit 1f4666e889497f92469ed9e2fa8de4d72f409432
Showing with 8 additions and 7 deletions.
  1. +8 −7 KServer.cs
View
@@ -20,13 +20,14 @@ public static string MachineType(this smo.Server s)
{
string serverType = "Unknown";
smo.Database d = s.Databases["master"];
string sql = @"IF EXISTS(SELECT *
FROM sys.all_columns
WHERE name = 'virtual_machine_type_desc'
AND OBJECT_NAME(object_id) = 'dm_os_sys_info')
BEGIN
SELECT virtual_machine_type_desc FROM sys.dm_os_sys_info
END";
string sql = @"IF EXISTS(SELECT *
FROM sys.all_columns
WHERE name = 'virtual_machine_type_desc'
AND OBJECT_NAME(object_id) = 'dm_os_sys_info')
BEGIN
EXECUTE sys.sp_executesql N'SELECT virtual_machine_type_desc FROM sys.dm_os_sys_info'
END
";
DataTable dt = d.ExecuteWithResults(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{

0 comments on commit 1f4666e

Please sign in to comment.