- 29 Dec 2022
- 1 Minute to read
- Contributors
- DarkLight
- PDF
Remove all badge records older the X days
- Updated on 29 Dec 2022
- 1 Minute to read
- Contributors
- DarkLight
- PDF
PROBLEM/NEED
I want to remove badge/user associations if the badges have not been used in a certain number of days. This can free up old badges so they can be used by different users.
SUMMARY
Badge/user association is stored in a SQL database. The records in the database include the last time a user tapped their badge (CacheTime column). Badge/user associations can be deleted based on the records with a CacheTime older than a certain amount of time.
STEPS
Verify the ProxCard SQL database
- To determine the ProxCard database, on an XA server, open the eXactACCESS Server Configuration utility, select the Database button, and verify the name of the database in the ProxCard tab:
- To determine the ProxCard database, on an XA server, open the eXactACCESS Server Configuration utility, select the Database button, and verify the name of the database in the ProxCard tab:
As a user that has permissions to read and write to the database , open the ProxCard SQL database with a tool that will allow you to run SQL queries (e.g. SQL Server Management Studio)
Run the following query to get the number of records that are older than X number of days (in the example, 90 is used). This will show you what records you are about to delete.
SELECT * FROM RFIDtoXAName
WHERE CacheTime <= DATEADD(day, -90, GETDATE())
ORDER BY CacheTime DESC
- Run the following query to delete records older than X number of days (in the example, 90 is used):
DELETE FROM RFIDtoXAName
WHERE CacheTime <= DATEADD(day, -90, GETDATE())