有人知道如何通过sql从microsoft sql server实例中获取操作系统信息吗?
使用SERVERPROPERTY可以获取一些信息,但我需要获取操作系统,例如‘'Microsoft NT 5.2 (3790)’
谢谢
发布于 2009-05-19 10:01:23
从@@版本摘录
例如:
PRINT @@VERSION
另一种方法是构建CLR函数或存储过程。下面是一个示例代码:
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());
}
};
此示例应输出以下内容:
SELECT dbo.Function1()
Microsoft Windows NT 6.0.6001 Service Pack 1
发布于 2009-05-19 09:47:10
我以前用过这样的东西:
exec master..xp_cmdshell 'systeminfo‘
https://stackoverflow.com/questions/881844
复制相似问题