Back to OIM Explorer

dbo.QBM_ZGetServerProperties

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 4.347 characters

Interpretation

  • Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.

Relations

  • No extracted relations.

Typed Edges

  • references source dbo.QBM_FCVIntToString source text reference
  • references source dbo.QBM_FCVStringToDigits source text reference
  • references source dbo.QBM_FCVStringToInt source text reference
  • references source dbo.QBM_FGIDBOwner source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL153 lines
1CREATE PROCEDURE QBM_ZGetServerProperties(2  @SlotNumberDummy int = 0,3  @Dummy1 varchar(38) = '',4  @Dummy2 varchar(38) = '',5  @DummyGenProcid varchar(38) = ''6)7AS8BEGIN9  DECLARE @MessageString nvarchar(max)10  DECLARE @x TABLE(LogDate datetime,11  ProcessInfo nvarchar(256) collate database_default,12  MessageString nvarchar(max))13  DECLARE @CountSockets int14  DECLARE @CountCoresPerSocket int15  DECLARE @CountLogicalProcessorsPerSocket int16  DECLARE @CountCoresTotal int17  DECLARE @CountLogicalProcessorsTotal int18  DECLARE @CoreDetect int19  DECLARE @patIndex nvarchar(64)20  DECLARE @DebugSwitch int = 021  DECLARE @IsQBMMaster BIT = 022  DECLARE @BlindMuster varchar(16) = '0'23  DECLARE @CURRENT_TIMEZONE_ID varchar(50) = NULL24  DECLARE @XUser nvarchar(64) = object_name(@@procid)25  DECLARE @Xdate datetime = getutcdate()26  DECLARE @HasExtendedProc BIT27  BEGIN TRY28    SELECT TOP 1 @HasExtendedProc = p.HasExtendedProc29    FROM QBM_VServerEngineProperties p30    IF dbo.QBM_FGIDBOwner() = 'QBM'31    BEGIN32      SELECT @IsQBMMaster = 133    END34    IF @HasExtendedProc = 035    BEGIN36      SELECT @CoreDetect = 037    END38    ELSE39    BEGIN40      INSERT INTO @x(LogDate,41      ProcessInfo,42      MessageString)43      EXEC sys.xp_readerrorlog 0,44      1,45      N 'detected',46      N 'socket'47      SELECT @CoreDetect = @@ROWCOUNT48    END49    IF @CoreDetect = 050    BEGIN51      SELECT @CountLogicalProcessorsPerSocket = COUNT(*)52      FROM sys.dm_os_schedulers53      WHERE54        status = N 'VISIBLE ONLINE';55      SELECT56        TOP 1 cpu_count,57        ceiling(convert(float, cpu_count) /convert(float, hyperthread_ratio)) AS CountSockets,58        hyperthread_ratio AS CountCoresPerSocket,59        cpu_count AS CountCoresTotal60      FROM sys.dm_os_sys_info61    END62    ELSE63    BEGIN64      SELECT TOP 1 @MessageString = x.MessageString65      FROM @x x66      ORDER BY x.LogDate DESC67      IF @DebugSwitch > 068      BEGIN69        print @MessageString70      END71      SELECT @patIndex = '%detected % sockets%'72      SELECT73        @CountSockets = dbo.QBM_FCVStringToInt(dbo.QBM_FCVStringToDigits(substring(@MessageString, patindex(@patIndex,74        @MessageString), len(@patIndex))),75        0)76      SELECT @patIndex = '%with % cores per socket%'77      SELECT78        @CountCoresPerSocket = dbo.QBM_FCVStringToInt(dbo.QBM_FCVStringToDigits(substring(@MessageString,79        patindex(@patIndex, @MessageString), len(@patIndex))),80        0)81      SELECT @patIndex = '%and % logical processors per s%'82      SELECT83        @CountLogicalProcessorsPerSocket = dbo.QBM_FCVStringToInt(dbo.QBM_FCVStringToDigits(substring(@MessageString,84        patindex(@patIndex, @MessageString), len(@patIndex))),85        0)86      SELECT @CountCoresTotal = @CountSockets * @CountCoresPerSocket87    END88    SELECT @CountLogicalProcessorsTotal = @CountSockets * @CountLogicalProcessorsPerSocket89    SELECT90      @CURRENT_TIMEZONE_ID = convert(varchar(50),91      CURRENT_TIMEZONE_ID())92    IF @CURRENT_TIMEZONE_ID IS NULL93    BEGIN94      SELECT @CURRENT_TIMEZONE_ID = CURRENT_TIMEZONE()95    END96    IF @DebugSwitch > 097    BEGIN98      print '@CountSockets' + str(@CountSockets) print '@CountCoresPerSocket' + str(@CountCoresPerSocket) print '@CountLogicalProcessorsPerSocket' +99      str(@CountLogicalProcessorsPerSocket) print '@CountCoresTotal' + str(@CountCoresTotal) print '@CountLogicalProcessorsTotal' + str(@CountLogicalProcessorsTotal100      ) print '@TimeZoneInformation (ID) ' + @CURRENT_TIMEZONE_ID101    END102    UPDATE DialogConfigParm103    SET Value = CASE104    WHEN isnull(t.Value,105    '') <> s.Wert THEN106    s.Wert107    ELSE t.Value108    END,109    XDateUpdated = @Xdate,110    XUserUpdated = @XUser111    FROM DialogConfigParm t112    JOIN(113    VALUES(CASE @IsQBMMaster114    WHEN 1 THEN115    @Blindmuster116    ELSE dbo.QBM_FCVIntToString(@CountSockets)117    END, 'QBM\DBServerProperties\CountSockets'),118    (CASE @IsQBMMaster119    WHEN 1 THEN120    @Blindmuster121    ELSE dbo.QBM_FCVIntToString(@CountCoresPerSocket)122    END, 'QBM\DBServerProperties\CountCoresPerSocket'),123    (CASE @IsQBMMaster124    WHEN 1 THEN125    @Blindmuster126    ELSE dbo.QBM_FCVIntToString(@CountLogicalProcessorsPerSocket)127    END, 'QBM\DBServerProperties\CountLogicalProcessorsPerSocket'),128    (CASE @IsQBMMaster129    WHEN 1 THEN130    @Blindmuster131    ELSE dbo.QBM_FCVIntToString(@CountCoresTotal)132    END, 'QBM\DBServerProperties\CountCoresTotal'),133    (CASE @IsQBMMaster134    WHEN 1 THEN135    @Blindmuster136    ELSE dbo.QBM_FCVIntToString(@CountLogicalProcessorsTotal)137    END, 'QBM\DBServerProperties\CountLogicalProcessorsTotal'),138    (CASE @IsQBMMaster139    WHEN 1 THEN140    'W. Europe Standard Time'141    ELSE @CURRENT_TIMEZONE_ID142    END, 'QBM\DBServerProperties\TimeZoneInformation')) AS s(Wert,143    Fullpath)144      ON t.Fullpath = s.Fullpath145  END TRY146  BEGIN CATCH147    EXEC QBM_PSessionErrorAdd DEFAULT148    RAISERROR('',149    18,150    1)151      WITH NOWAIT152  END CATCH153END
Open raw exported source
SQL ยท Raw29 lines
1       create   procedure QBM_ZGetServerProperties (@SlotNumberDummy int = 0 , @Dummy1 varchar(38) = '' , @Dummy2 varchar(38) = '' , @DummyGenProcid2 varchar(38) = '' ) as begin declare @MessageString nvarchar(max) declare @x table (LogDate datetime , ProcessInfo nvarchar(256) collate database_default3 , MessageString nvarchar(max) ) declare @CountSockets int declare @CountCoresPerSocket int declare @CountLogicalProcessorsPerSocket int declare @CountCoresTotal4 int declare @CountLogicalProcessorsTotal int declare @CoreDetect int declare @patIndex nvarchar(64) declare @DebugSwitch int = 0 declare @IsQBMMaster 5bit = 0 declare @BlindMuster varchar(16) = '0' declare @CURRENT_TIMEZONE_ID varchar(50) = null  declare @XUser nvarchar(64) = object_name(@@procid) declare6 @Xdate datetime = getutcdate() declare @HasExtendedProc bit BEGIN TRY select top 1 @HasExtendedProc = p.HasExtendedProc from QBM_VServerEngineProperties7 p if dbo.QBM_FGIDBOwner() = 'QBM' begin select @IsQBMMaster = 1 end if @HasExtendedProc = 0  begin select @CoreDetect = 0 end else begin insert into @x8(LogDate, ProcessInfo, MessageString) EXEC sys.xp_readerrorlog 0, 1, N'detected', N'socket' select @CoreDetect = @@ROWCOUNT end if @CoreDetect = 0 begin9  select @CountLogicalProcessorsPerSocket = COUNT(*) FROM sys.dm_os_schedulers WHERE status = N'VISIBLE ONLINE'; SELECT top 1 cpu_count, ceiling(convert10(float, cpu_count)/convert(float,hyperthread_ratio)) AS CountSockets , hyperthread_ratio AS CountCoresPerSocket , cpu_count AS CountCoresTotal FROM sys.dm_os_sys_info11 end else begin select top 1 @MessageString = x.MessageString from @x x order by x.LogDate desc if @DebugSwitch > 0 begin print @MessageString end select12 @patIndex = '%detected % sockets%' select @CountSockets = dbo.QBM_FCVStringToInt( dbo.QBM_FCVStringToDigits( substring(@MessageString, patindex(@patIndex13, @MessageString) , len(@patIndex))), 0) select @patIndex = '%with % cores per socket%' select @CountCoresPerSocket = dbo.QBM_FCVStringToInt( dbo.QBM_FCVStringToDigits14( substring(@MessageString, patindex(@patIndex, @MessageString) , len(@patIndex))), 0) select @patIndex = '%and % logical processors per s%' select @CountLogicalProcessorsPerSocket15 = dbo.QBM_FCVStringToInt( dbo.QBM_FCVStringToDigits( substring(@MessageString, patindex(@patIndex, @MessageString) , len(@patIndex))), 0) select @CountCoresTotal16 = @CountSockets * @CountCoresPerSocket end select @CountLogicalProcessorsTotal = @CountSockets * @CountLogicalProcessorsPerSocket            select @CURRENT_TIMEZONE_ID17 = convert(varchar(50), CURRENT_TIMEZONE_ID())  if @CURRENT_TIMEZONE_ID is null begin select @CURRENT_TIMEZONE_ID = CURRENT_TIMEZONE()  end if @DebugSwitch18 > 0 begin print '@CountSockets' + str(@CountSockets) print '@CountCoresPerSocket' + str(@CountCoresPerSocket) print '@CountLogicalProcessorsPerSocket'19 + str(@CountLogicalProcessorsPerSocket) print '@CountCoresTotal' + str(@CountCoresTotal) print '@CountLogicalProcessorsTotal' + str(@CountLogicalProcessorsTotal20) print '@TimeZoneInformation (ID) ' + @CURRENT_TIMEZONE_ID end update DialogConfigParm set Value = case when isnull(t.Value, '') <> s.Wert then s.Wert21 else t.Value end , XDateUpdated = @Xdate , XUserUpdated = @XUser from DialogConfigParm t join ( values (case @IsQBMMaster when 1 then @Blindmuster else22 dbo.QBM_FCVIntToString(@CountSockets) end, 'QBM\DBServerProperties\CountSockets') , ( case @IsQBMMaster when 1 then @Blindmuster else dbo.QBM_FCVIntToString23(@CountCoresPerSocket) end, 'QBM\DBServerProperties\CountCoresPerSocket') , (case @IsQBMMaster when 1 then @Blindmuster else dbo.QBM_FCVIntToString(@CountLogicalProcessorsPerSocket24) end, 'QBM\DBServerProperties\CountLogicalProcessorsPerSocket') , (case @IsQBMMaster when 1 then @Blindmuster else dbo.QBM_FCVIntToString(@CountCoresTotal25) end, 'QBM\DBServerProperties\CountCoresTotal') , (case @IsQBMMaster when 1 then @Blindmuster else dbo.QBM_FCVIntToString(@CountLogicalProcessorsTotal26) end, 'QBM\DBServerProperties\CountLogicalProcessorsTotal') , (case @IsQBMMaster when 1 then 'W. Europe Standard Time' else @CURRENT_TIMEZONE_ID end, 27'QBM\DBServerProperties\TimeZoneInformation') ) as s (Wert, Fullpath) on t.Fullpath = s.Fullpath END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default 28RAISERROR ('', 18, 1) WITH NOWAIT END CATCH end 29