This article describes how to reduce TRBOnet database size to prevent upgrade failures and database corruption when using Microsoft SQL Server Express with a 10 GB database size limit.
When the database reaches the limit, new data cannot be written. During a TRBOnet upgrade, the database structure changes and size may increase by 20 to 30 percent.
If the database size is close to the limit at 8 to 10 GB, the upgrade may fail or cause database corruption.
Database Modes
| Mode | Description |
|---|---|
| MULTI_USER | Default and normal operating mode for databases. There are no restrictions on the number of connections. Users can read/write and modify data |
| SINGLE_USER | Transactions are rolled back. Database is available for administrative maintenance. |
| EMERGENCY | Indicates possible corruption. Database may be in inconsistent state. Data recovery may not be possible. |
Before new version install
Database upgrade attempt was unsuccessful due to database size limit
Step 1: Check Database State
Step 2: Stop TRBOnet Service
Step 3: Identify Large Tables
Before making changes, check which tables use the most space.
GO
sp_msforeachtable N'EXEC sp_spaceused [?]';
GO
This script shows the size of each table, including related objects such as indexes.
Step 4: Rebuild Indexes
Step 5: Shrink the Database
After rebuilding indexes, SQL Server still reserves space based on previous data size.
To reclaim unused space, shrink the database:
Step 6: Delete Old Data
Example for the table with GPS data :
EXEC @return_value = [dbo].[sp_ClearOldData]
@tableName = N'GpsInfo',
@dateColumnName = N'date',
@date = '2022-11-07 00:00 +03:00'
The procedure deletes all records older than the specified date, starting from the oldest records. Make sure the date is correct before running the script.
Example for the table with GPS data :
WHERE [date] < '2022-11-07 00:00'
Step 7: Shrink the Database
After deleting old data, perform another database shrink to reclaim the freed space.
Step 8: Run Database Upgrade
Run the database upgrade after all maintenance steps are completed.