Remove all badge records older the X days
  • 29 Dec 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Remove all badge records older the X days

  • Dark
    Light
  • PDF

Article summary

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

  1. Verify the ProxCard SQL database

    1. 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:
      image.png
  2. 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)
    image.png

  3. 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 

  1. 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())

Was this article helpful?