Audit Scripts: Activity Billed/Unbilled row counts
After you have backed up financial information like Time Entries, Expense Entries, and Fee Entries it is a good idea to audit the results prior to restoring data to the destination system. For example, some Universal Destinations support restoring unbilled Work In Progress (WIP), but not activities that have been previously billed. Therefore, ensuring that the invoiced status was backed up correctly is very important.
The below query is a quick audit to confirm that the invoiced status of Time, Expense, and Fee activities were backed up correctly.
- SELECT
- '__M_Financial_Activities_Expenses' tableName,
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed') billedStatus,
- COUNT(*)
- FROM
- __M_Financial_Activities_Expenses
- WHERE 1=1
- AND Final_Status != 'Deleted'
- GROUP BY
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed')
- UNION
- SELECT
- '__M_Financial_Activities_Fees' tableName,
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed') billedStatus,
- COUNT(*)
- FROM
- __M_Financial_Activities_Fees
- WHERE 1=1
- AND Final_Status != 'Deleted'
- GROUP BY
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed')
- UNION
- SELECT
- '__M_Financial_Activities_Time' tableName,
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed') billedStatus,
- COUNT(*)
- FROM
- __M_Financial_Activities_Time
- WHERE 1=1
- AND Final_Status != 'Deleted'
- GROUP BY
- IIF(Final_ArInvoice_Id = '', 'Unbilled', 'Billed')
Related Articles
Audit Scripts: Row Counts and Progress Monitoring
This article shows you a script that can be used to monitor the progress of both a Backup and a Restore. It can also be used to just review row counts on all the Universal Database tables. The first code block is used to populate a SQL Server Temp ...
Audit Scripts: General Audit
After completing a backup there are a number of things that are good to review prior to restoring into the destination system. The script below reviews several of the data points that should be looked at prior to restoring. This script is not ...
Other: Total Record Counts
The following SQL script will count all records in all tables in a database. DECLARE @TableRowCounts TABLE ([TableName] VARCHAR(128), [RowCount] INT) ; INSERT INTO @TableRowCounts ([TableName], [RowCount]) EXEC sp_MSforeachtable 'SELECT ''?'' ...
Other: Obtaining Record Counts for all Tables
The following script will count all records in all tables. DECLARE @TableRowCounts TABLE ( [TableName] VARCHAR(128), [Action_Group] INT, [Incomplete] INT, [Complete] INT, [Total] INT ) ; INSERT INTO @TableRowCounts ( [TableName], [Action_Group], ...
Delta Compare Two Backups
Sometimes, you may want to do an Alpha/Delta compare of two backups of a firms data. This can allow you to spot data trends and changes over time. ...