How to retrieve last 10 scan results from the Database
ON-PREMISES
Applies to Gizmo 1.9+
This article describes how to retrieve 10 (configurable) scan results directly from a SQL Query in SQL Management Studio.
Instructions
Connect to SQL Management Studio and to the Gizmo Database.
Create New Query.
Paste the following query:
CREATE OR ALTER PROCEDURE [dbo].[Analysis_Generation_Print_V1] ( @text NVARCHAR(MAX) ) AS BEGIN DECLARE @CurrentEnd BIGINT; DECLARE @offset tinyint; set @text = replace( replace(@text, char(13) + char(10), char(10)) , char(13), char(10)) WHILE LEN(@text) > 1 BEGIN IF CHARINDEX(CHAR(10), @text) between 1 AND 4000 BEGIN SET @CurrentEnd = CHARINDEX(char(10), @text) -1 set @offset = 2 END ELSE BEGIN SET @CurrentEnd = 4000 set @offset = 1 END PRINT SUBSTRING(@text, 1, @CurrentEnd) set @text = SUBSTRING(@text, @CurrentEnd+@offset, LEN(@text)) END END; GO DECLARE @TemplateGuid UNIQUEIDENTIFIER = 'd854f97f-a776-4a7c-a886-91790c6c3c31'; DECLARE @nbRes INT = 10; DECLARE @result NVARCHAR(MAX) DECLARE db_cursor CURSOR FOR SELECT TOP(@nbRes) scan.ScanResult FROM DataTier_ScanHot scan JOIN ScanConfig_RobotApps app ON scan.RobotWorkerGuid = app.Guid JOIN ScanConfig_ScanConfigurations conf ON app.ScanConfigurationGuid = conf.Guid WHERE conf.TemplateGuid = @TemplateGuid OPEN db_cursor FETCH NEXT FROM db_cursor INTO @result WHILE @@FETCH_STATUS = 0 BEGIN EXEC [dbo].[Analysis_Generation_Print_V1] @result FETCH NEXT FROM db_cursor INTO @result END CLOSE db_cursor DEALLOCATE db_cursor
Edit (if needed) the “TemplateGuid” on line 28 with the platform you are looking for (Mailbox Server corresponds to “d854f97f-a776-4a7c-a886-91790c6c3c31“).
Save results in a file by clicking Save Results As…
A “.rpt” file is now saved and contains the results.