dbo.QBM_PIndexRebuild
SQL_STORED_PROCEDURE
Created 2025-06-27T17:57:28.800 · modified 2026-04-14T23:20:25.440 · source: live DB sys.objects/sys.sql_expression_dependencies.
Parameters
| Name | Type | Output |
|---|---|---|
@TableName | varchar | no |
Referenced objects
| Schema | Object | Column/minor | Class |
|---|---|---|---|
| DialogDBQueue | OBJECT_OR_COLUMN | ||
| QBM_PDBQueueInsert_Single | OBJECT_OR_COLUMN | ||
| QBM_PExecuteSQLWithRetry_LLP | OBJECT_OR_COLUMN | ||
| QBM_PGIDBServerIndexRebuildOpt | OBJECT_OR_COLUMN | ||
| QBM_PJournal | OBJECT_OR_COLUMN | ||
| QBM_PSessionErrorAdd | OBJECT_OR_COLUMN | ||
| QBM_PSetRowLockOnly | OBJECT_OR_COLUMN | ||
| QBM_PTableLockEscalationSet | OBJECT_OR_COLUMN | ||
| QBM_VHeavyLoadTables | OBJECT_OR_COLUMN | ||
| QBM_YCursorBuffer | TYPE | ||
| QBM_YSessionError | TYPE | ||
| dbo | QBM_FGISessionContext | OBJECT_OR_COLUMN | |
| dbo | QBM_FTIndexFragmentation | OBJECT_OR_COLUMN |
Source excerpt
First extracted SQL definition lines from the exported source. Use the full source page for complete context.
1 create procedure QBM_PIndexRebuild ( @TableName varchar(30) ) as begin declare @SQLcmd nvarchar(max) declare @tableID int declare @SQLcmds 2QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int declare @DebugLevel char(1) = 'W' declare @GenProcID varchar(38) = dbo.QBM_FGISessionContext 3('') declare @RebuildOptions nvarchar(max) declare @ErrorBuffer QBM_YSessionError SET XACT_ABORT OFF BEGIN TRY if @@TRANCOUNT > 0 begin goto endlabel 4end if isnull(@TableName, '') = '' begin goto ende end select @tableID = null select top 1 @tableID = OBJECT_ID from sys.tables where name = @TableName 5 exec QBM_PTableLockEscalationSet @TableName if @TableName in (select TableName from QBM_VHeavyLoadTables ) begin goto ende end if not exists (select 6 top 1 1 from information_schema.tables where table_name = @TableName and table_type = 'BASE TABLE' ) or @tableID is null begin select @SQLcmd = N'No reorganize for Table ' 7 + @TableName + N' Table not exists' exec QBM_PJournal @SQLcmd, @@procid, 'W', @DebugLevel goto ende end exec QBM_PGIDBServerIndexRebuildOpt @TableName 8, @RebuildOptions output set lock_timeout 5000 select @ElementCount = 0 BEGIN TRY insert into @SQLcmds (ContentFull) SELECT N'ALTER INDEX "' + x.indexname 9 + N'" ON ' + schemaname + N'.' + @TableName + case when x.PercentFrag < 20.0 and x.index_id > 1 then N' REORGANIZE' else @RebuildOptions end from dbo.QBM_FTIndexFragmentation 10(@TableName, 5) x order by x.index_id select @ElementCount = @@rowcount END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default insert into @ErrorBuffer 11(ErrorMessage, ErrorSeverity, ErrorState, ErrorNumber , ProcedureName, ProcedureLine, MessageDate , GenProcID, RepeatCounter, IsReThrow, SourceCode) select 12 ERROR_MESSAGE(),ERROR_SEVERITY(), ERROR_STATE(), 50000 , ERROR_PROCEDURE() , ERROR_LINE(), GETUTCDATE() , null, 0, 0, 'select fr.object_id, fr.index_id ...FROM sys.dm_db_index_physical_stats ...' 13 exec QBM_PSessionErrorAdd @ErrorBuffer raiserror ('', 18, 1) END CATCH if @ElementCount > 0 begin select @SQLCmd = N'ALTER INDEX ALL ON ' + @TableName 14 + N' SET (ALLOW_PAGE_LOCKS = ON)' exec QBM_PJournal @SQLcmd, @@PROCID , 'D', @DebugLevel exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLcmd , @LockTimeout_ms 15 = default , @MaxWaitTimeForLock_s = default , @ProcIDForJournal = @@procid , @HandleErrorSilent = 0 , @ExecuteWithTransact = 0 select @ElementIndex = 16 1 while @ElementIndex <= @ElementCount begin select top 1 @SQLcmd = bu.ContentFull from @SQLcmds bu where bu.ElementIndex = @ElementIndex exec QBM_PJournal 17 @sqlcmd, @@PROCID, 'D', @DebugLevel exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLcmd , @LockTimeout_ms = default , @MaxWaitTimeForLock_s = 10.0 18 , @ProcIDForJournal = @@procid , @HandleErrorSilent = 0 , @ExecuteWithTransact = 0 select @ElementIndex += 1 end end exec QBM_PSetRowLockOnly @TableName 19 if not exists (select top 1 1 from DialogDBQueue q with (readpast) where q.UID_Task = 'QBM-K-UpdateStatistics' ) begin exec QBM_PDBQueueInsert_Single 20'QBM-K-UpdateStatistics', '', '', @GenProcID end ende: return END TRY BEGIN CATCH exec QBM_PSetRowLockOnly @TableName exec QBM_PSessionErrorAdd default 21 raiserror ('', 18, 1) END CATCH endLabel: return end 22
Module relation graph
Loading module relation graph…
Source-derived context
Generated from exported SQL module definitions plus read-only sandbox sys.objects/sys.parameters/sys.sql_expression_dependencies metadata. This is factual source evidence, not a semantic guess.
provenance: SQL definition export provenance: sandbox DB metadata modified: 2026-04-14T23:20:25.440
inserts DBQueue tasks uses session context values has TRY/CATCH error handling
Summary: calls QBM_PTableLockEscalationSet, QBM_PJournal, QBM_PGIDBServerIndexRebuildOpt, QBM_PSessionErrorAdd, QBM_PExecuteSQLWithRetry_LLP…; writes INSERT into; reads/joins sys, QBM_VHeavyLoadTables, information_schema, QBM_FTIndexFragmentation, DialogDBQueue
Declared parameters
| Parameter | Type | Direction |
|---|---|---|
@TableName | varchar(30) | input |
DML targets
INSERT intoCalled routines
Read/join references
SQL dependency metadata
Config/session
Config: None extracted.
Session: None extracted.
DBQueue/tasks
QBM-K-UpdateStatisticsTemp tables / referenced variables
Temp: None extracted.
Variables: @TableName @SQLcmd @tableID @SQLcmds @ElementCount @ElementIndex @DebugLevel @GenProcID @RebuildOptions @ErrorBuffer @TRANCOUNT @procid @rowcount @SQLCmd @PROCID @SQLStatement @LockTimeout_ms @MaxWaitTimeForLock_s @ProcIDForJournal @HandleErrorSilent @ExecuteWithTransact @sqlcmd
Referenced by / reverse dependencies
Generated from live DB metadata, FK rows, and exported SQL dependency/source extraction. This is factual linkage evidence, not inferred behavior.
| Referencing object | Relation | Evidence |
|---|---|---|
| dbo.QBM_ZIndexRebuild | SQL expression dependency | OBJECT_OR_COLUMN |
| dbo.QBM_ZIndexRebuild | source text reference | creates object-layer jobs via QBM_PJobCreate*, uses session context values, has TRY/CATCH error handling |