Monday, 19 May 2025

CRM on prem server Maintennace Job

 Regarding the index maintenance job, its purpose is to optimize performance by managing indexes, dropping, and recreating them as needed. This process helps prevent SQL errors caused by index length and fragmentation. 

UPDATE ScaleGroupOrganizationMaintenanceJobs

SET RecurrenceStartTime = '2025-05-18 23:30:00.000', RecurrencePattern = 'FREQ=DAILY;INTERVAL=2;', NextRunTime = '2025-05-18 23:30:00.000'

WHERE OperationType in (30, 15) AND OrganizationId = 'place the Organization ID'; 

1. RecurrenceStartTime: Sets the start time for the recurrence to '2025-05-18 23:30:00.000'.
2. RecurrencePattern: Sets the recurrence pattern to 'FREQ=DAILY;INTERVAL=2;', meaning the job will run once every 2 days.
3. NextRunTime: Sets the next run time to '2025-05-18 23:30:00.000.
4. OperationType: Filters the jobs to update by their operation types (15 for Index Management and 30 for Reindexing).
5. OrganizationId: Filters the jobs by the specific organization ID.

SQL Server Index statistic

 Run below query. If any sampling percentage is between 0.1 and 5, then re-build the index and run the statistic

DECLARE @DatabaseName NVARCHAR(255) = 'Database_Name';

 

-- Create a temporary table to store results

CREATE TABLE #StatsUpdateInfo

(

   TableName NVARCHAR(255),

   StatsName NVARCHAR(255),

   RowsModified INT,

   RowsSampled INT,

   SamplingPercentage FLOAT

);

 

-- Cursor to iterate through each table in the database

DECLARE @TableName NVARCHAR(255);

DECLARE table_cursor CURSOR FOR

   SELECT t.name

   FROM sys.tables t

   WHERE t.is_ms_shipped = 0;

 

-- Variables to store dynamic SQL

DECLARE @SQL NVARCHAR(MAX);

 

OPEN table_cursor;

FETCH NEXT FROM table_cursor INTO @TableName;

 

WHILE @@FETCH_STATUS = 0

BEGIN

   -- Dynamic SQL to gather statistics update information for each table

   SET @SQL = '

       INSERT INTO #StatsUpdateInfo

       SELECT

           ''' + @TableName + ''' AS TableName,

           s.name AS StatsName,

           us.rows AS RowsModified,

           us.rows_sampled AS RowsSampled,

           CASE WHEN us.rows_sampled > 0 THEN CAST(us.rows_sampled * 100.0 / us.rows AS FLOAT) ELSE 0 END AS SamplingPercentage

       FROM

           ' + QUOTENAME(@DatabaseName) + '.sys.tables t

           JOIN ' + QUOTENAME(@DatabaseName) + '.sys.stats s ON t.object_id = s.object_id

           OUTER APPLY sys.dm_db_stats_properties(t.object_id, s.stats_id) us

       WHERE

           t.name = ''' + @TableName + ''';

   ';

 

   -- Execute dynamic SQL

   EXEC sp_executesql @SQL;

 

   FETCH NEXT FROM table_cursor INTO @TableName;

END

 

CLOSE table_cursor;

DEALLOCATE table_cursor;

 

-- Select the results

SELECT *

FROM #StatsUpdateInfo;

 

-- Drop the temporary table

DROP TABLE #StatsUpdateInfo;

 

SSRS Logs On Prem

 Open the below folder to check the SSRS error on the on prem server

c:\program files\Microsoft sql server reporting services\ssrs\logfiles

Wednesday, 14 May 2025

Command Checker for model-app ribbons

 To enable Command Checker, pass ribbondebug=true as a URL parameter (ex: https://myorg.crm.dynamics.com/main.aspx?appid=c26d1c44-e7c0-4c72-9d6d-0e82768cb5bd&ribbondebug=true).  You’ll see two new UI features light up.  The first is a new button in the top right of the header which lets you inspect the global command bar


Introducing Command Checker for model-app ribbons - Microsoft Power Platform Blog