In SQL PI, when viewing collected SQL batches, the batch name typically reflects the nature of the SQL:
"ad-hoc batch"."system procedure".dbo.C_SP_Stock_Level;1.However, in some cases, the batch name appears as a numeric object reference, such as:
Object -6:1671677003;1
This format indicates that SQL PI was unable to resolve the object name at the time of collection.
This issue usually occurs when the Foglight monitoring user lacks sufficient permissions to access the database or object during data collection. Common scenarios include:
foglightuser login exists, but the SID does not match the database user.As a result, SQL PI falls back to displaying the internal object reference format:Object <dbid>:<object_id>;1
Ensure the foglightuser has access to the affected database:
Use the standard Foglight permissions script to reassign roles and access.
If the database was restored from another instance:
USE [YourDatabaseName];DROP USER [foglightuser];CREATE USER [foglightuser] FOR LOGIN [foglightuser];
This remaps the user to the correct login SID.
Look for batch names in SQL PI like:
Object 6:1671677003;1
Extract:
dbid = 6object_id = 1671677003
Run this query on the monitored SQL Server instance:
SELECTqs.sql_handle,st.textFROM sys.dm_exec_query_stats AS qsCROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS stWHERE st.objectid = 1671677003 AND st.dbid = 6;
Copy the sql_handle from the result.
Connect to the SQL PI repository using Toad or SSMS.
DECLARE @i INT = 0;DECLARE @sql NVARCHAR(MAX);DECLARE @sql_handle NVARCHAR(128) = 'your_sql_handle_here'; -- Replace with actual sql_handleDECLARE @table_name NVARCHAR(100);DECLARE @row_count INT;-- Table to store preview resultsIF OBJECT_ID('tempdb..#DeletePreview') IS NOT NULL DROP TABLE #DeletePreview;CREATE TABLE #DeletePreview (table_name NVARCHAR(100),rows_to_delete INT);WHILE @i < 30BEGINSET @table_name = 'pass_batch_dim_p' + CAST(@i AS VARCHAR(2));SET @sql = 'INSERT INTO #DeletePreview (table_name, rows_to_delete)SELECT ''' + @table_name + ''', COUNT(*)FROM ' + QUOTENAME(@table_name) + 'WHERE sql_handle = @sql_handle;';EXEC sp_executesql @sql, N'@sql_handle NVARCHAR(128)', @sql_handle;SET @i = @i + 1;END-- Show summary of rows that would be deletedSELECT * FROM #DeletePreviewORDER BY rows_to_delete DESC;
Replace <sql_handle> with the actual value retrieved in Step 3.
sql_handles from each one. Connect to the SQL PI repository using Toad or SSMS.
DECLARE @i INT = 0;DECLARE @sql NVARCHAR(MAX);DECLARE @sql_handle NVARCHAR(128) = 'your_sql_handle_here'; -- Replace with actual sql_handleDECLARE @table_name NVARCHAR(100);-- Table to store log resultsIF OBJECT_ID('tempdb..#DeleteLog') IS NOT NULL DROP TABLE #DeleteLog;CREATE TABLE #DeleteLog (table_name NVARCHAR(100),rows_deleted INT);WHILE @i < 30BEGINSET @table_name = 'pass_batch_dim_p' + CAST(@i AS VARCHAR(2));SET @sql = 'DECLARE @count INT;DELETE FROM ' + QUOTENAME(@table_name) + 'WHERE sql_handle = @sql_handle;SET @count = @@ROWCOUNT;INSERT INTO #DeleteLog (table_name, rows_deleted) VALUES (''' + @table_name + ''', @count);';EXEC sp_executesql @sql, N'@sql_handle NVARCHAR(128)', @sql_handle;SET @i = @i + 1;END-- Show summary of deletionsSELECT * FROM #DeleteLogORDER BY rows_deleted DESC;
<sql_handle> with the actual value retrieved in Step 3.sql_handle from each one. Important: Before running the script below, ensure you have a full backup of the SQL PI repository database.
This script will permanently delete rows from allpass_batch_dim_pXtables for the specifiedsql_handle.
Once deleted, this data cannot be recovered unless a backup is available.
After deletion, SQL PI will reprocess the batch from the 1-minute tables (pass_batch_dim_1m_*) during the next collection cycle. If permissions are now correct, the batch name will be resolved properly.
CREATE USER FOR LOGIN.USE [RestoredDB];DROP USER [foglightuser];CREATE USER [foglightuser] FOR LOGIN [foglightuser];
sp_change_users_login or ALTER USER ... WITH LOGIN.