Does anyone know how to get the operating system information from a microsoft sql server instance via sql?
Using SERVERPROPERTY can get some information but I need to get the operating system e.g. 'Microsoft Windows NT 5.2 (3790)'
Thanks
Does anyone know how to get the operating system information from a microsoft sql server instance via sql?
Using SERVERPROPERTY can get some information but I need to get the operating system e.g. 'Microsoft Windows NT 5.2 (3790)'
Thanks
I've used something like this before:
exec master..xp_cmdshell 'systeminfo'
Extract from @@VERSION
Eg:
PRINT @@VERSION
Another way is to build a CLR Function or Stored Procedure. Here is a sample code:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString Function1()
{
return new SqlString(System.Environment.OSVersion.ToString());
}
};
This example should output this:
SELECT dbo.Function1()
Microsoft Windows NT 6.0.6001 Service Pack 1