首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >tsql以了解服务器是否具有集成、报告、分析和通知服务

tsql以了解服务器是否具有集成、报告、分析和通知服务
EN

Stack Overflow用户
提问于 2009-11-05 06:30:51
回答 1查看 589关注 0票数 0

我想知道服务器是否具有集成、报告、分析和通知服务,而不考虑版本(2000或2005)。

目前,我正在使用

代码语言:javascript
运行
复制
xp_cmdshell 'net start'

但是它包含了太多的信息。

有什么帮助吗?

EN

Stack Overflow用户

发布于 2009-11-05 08:43:53

以下是2005/2008代码。对于2000年,您必须自己在注册表中摸索,因为我相信它存储在其他地方。此外,您还必须将其从表变量更改为实际的临时表。

好好享受吧。

代码语言:javascript
运行
复制
Declare @Instances Table
(InstanceName SysName, RegKey SysName, InstanceType Character Varying(50), 
 Version Character Varying(4), Features National Character Varying(2000))

Insert Into @Instances(InstanceName, RegKey)
Execute Master.dbo.xp_RegEnumValues N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\Instance Names\SQL'
Update @Instances Set InstanceType = 'SQL Server' Where InstanceType Is Null

Insert Into @Instances(InstanceName, RegKey)
Execute Master.dbo.xp_RegEnumValues N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\Instance Names\RS'
Update @Instances Set InstanceType = 'Reporting Services' Where InstanceType Is Null

Insert Into @Instances(InstanceName, RegKey)
Execute Master.dbo.xp_RegEnumValues N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\Instance Names\OLAP'
Update @Instances Set InstanceType = 'Analysis Services' Where InstanceType Is Null

Declare 
 @More Bit, @CRegKey SysName, @RegPath National Character Varying(2000),
 @Features National Character Varying(2000), @VersionString National Character Varying(500) 

Declare CInstance Cursor
For
Select RegKey From @Instances

Open CInstance
Set @More = 1

While (@More = 1)
Begin
 Fetch Next From CInstance Into @CRegKey
 If (@@Fetch_Status != 0)
  Set @More = 0
 Else
     Begin
   Set @RegPath = N'Software\Microsoft\Microsoft SQL Server\' + @CRegKey + '\Setup'

   Execute Master.dbo.xp_RegRead N'HKEY_LOCAL_MACHINE', @RegPath, N'FeatureList', @Features Output, 'no_output'
   Execute Master.dbo.xp_RegRead N'HKEY_LOCAL_MACHINE', @RegPath, N'PatchLevel', @VersionString Output, 'no_output'
   -- \' ignore this, it's just to get the formatting right 
   Update @Instances
   Set
    Features = @Features,
    Version = (Case When Left(@VersionString, 1) = '9' Then '2005'
                    When Left(@VersionString, 2) = '10' Then '2008'
                    Else '????' End)
   Where Current Of CInstance
  End
End    

Close CInstance
Deallocate CInstance

Update @Instances Set InstanceName = '(local)' Where InstanceName = 'MSSQLServer'

Select InstanceName, InstanceType, Version, Features 
From @Instances
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1677124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档