So I’ve been moving a Sitecore website to a live server, and one of the problems I had was that the analytics database already had data in it. The MongoDB instance was new, so that was empty – but how do I clear our test/development data out of the Analytics database?
Well it turns out that there is a stored procedure – __DeleteAllReportingData – in the Analytics database for just that:
Run that, and all your data will be gone. Obviously, use with care – but useful.
It seems to work by removing all foreign keys, truncating each table, and adding the keys back, so the user running this will need permission to do all these things.
Also, you can exclude tables, but I just ran it with the input of an empty string ( ” ) to clear all.