declare @OutputType varchar(20)
declare @debug char(1)
declare @ForceRefresh
char(1)
declare @xp_cmdshell_available char(1)
set
@OutputType='LIST'
set @Debug= 'Y'
set
@ForceRefresh= 'Y'
set @xp_cmdshell_available =
'Y'
begin
set nocount on
declare @id int
declare @id2
int
declare @Line varchar(300)
declare @CurrentCmd varchar(30)
declare @Cmd
varchar(300)
declare @Node varchar(100)
declare @Resource varchar(100)
declare @Status varchar(20)
declare @i int
declare @Group varchar(100)
declare @Num varchar(10)
declare @ClusterID int
declare @tmp int
declare
@ThisGroupsCurrentNode varchar(100)
declare @DoneClusterName char(1)
declare
@RunningOnACluster char(1)
declare @Line2 varchar(300)
declare @SQLName
sysname
declare @WindowsMachineName sysname
declare @PreferredServer sysname
declare @SQL varchar(4100)
declare @FailCnt int
declare @PreferredServers
int
declare @z int
declare @CurrentSQLServerGroup sysname
declare
@CurrentSQLServer sysname
declare @QuorumResource varchar(300)
declare
@CreatedTempTables char(1)
declare @LoopGroup varchar(300)
declare
@PreferredServerExists char(1)
if @Debug = 'Y' print convert(varchar
(30),getdate(),109) + ': ' + object_name(@@procid) + ' started.'
select @DoneClusterName = 'N'
--驗證@OutputType類型
if lower
(@OutputType) in ('q', 'quick', 's', 'summary',
'sum') select @OutputType = 'Quick'
else if lower(@OutputType) in
('l', 'list') select @OutputType = 'List'
else
begin
select @Cmd = 'Error in ' + object_name(@@procid) +
':
@OutputType parameter must be ''Quick'' or ''List'', not
''' +
isnull(@OutputType,'<null>') +
'''.'
raiserror 50001 @Cmd
return
end
if UPPER
(@xp_cmdshell_available) in ('Y','')
SET @xp_cmdshell_available =
'Y'
else
SET @xp_cmdshell_available = 'N'
if @Debug =
'Y' print convert(varchar(30),getdate(),109) + ': Calling
Spot_CheckCluster...'
select @FailCnt = 0, @PreferredServers = 0
--檢查 xp_cmdshell是否開啟
--declare @LocalTable table(result int, ErrorCode int)
--
insert into @LocalTable
-- execute QS_SoSS58_CheckCmdShell
--if 1 <>
(select count(*) from @LocalTable where result = 1)
if (0 = (select
value_in_use from sys.configurations where name = 'xp_cmdshell'))
set
@xp_cmdshell_available = 'N'
select @RunningOnACluster = case when
convert(int,serverproperty('IsClustered')) = 1 then 'Y' else 'N'
end
set @SQLName = convert(sysname,serverproperty('ServerName'))
set @WindowsMachineName = convert(sysname,serverproperty
('MachineName'))
if @Debug = 'Y' print convert(varchar
(30),getdate(),109) + ': 創建臨時表...'
create table #w3
(id int
identity,
ParentID int null,
Type varchar(20) null,
Name sysname
null,
OtherData sysname null,
Status varchar(20) null,
Comment varchar
(255) null,
PreferredServerExists char(1),
RunningOnPreferredServer char(1)
null,
ControlsTheCurrentSQLServer char(1) null,
TakeOfflineCmd char(1)
null,
BringOnlineCmd char(1) null,
MoveGroupCmd char(1) null,
StopMSCSCmd char(1) null,
StartMSCSCmd char(1) null,
RunningOnServer sysname
null,
Sequencer smallint null
)
create table #w4 (id int identity
(1,1), group_name varchar(255) NULL)
create table #CmdOutput
(
id int
identity,
OutputLine varchar(255) null
)
create unique clustered index
#PK_CmdOutput on #CmdOutput(id)
select @CreatedTempTables = 'Y'