Tags: Optimizely/Episerver SQL

Delete content directly from the Optimizely database

Your Optimizely Content Cloud website could contain orphaned blocks or other content items that it's not possible to delete from edit mode. How can this happen?

Now, block B still exists, but there is no way of deleting it! Unless you run the scheduled job Remove Unrelated Content Assets... 

...or, you're friends with the database!

DELETE from tblContentLanguage WHERE fkContentID = 1337
DELETE FROM tblContentProperty WHERE fkContentID = 1337
DELETE FROM tblWorkContentProperty WHERE fkWorkContentID IN (SELECT pkID FROM tblWorkContent WHERE fkContentID = 1337)
DELETE FROM tblWorkContent WHERE fkContentID = 1337
DELETE from tblContent WHERE pkID = 1337

Just replace 1337 with the content id you want to delete. If you forget the WHERE clause, you're of course in big trouble. Don't do that, or you might end up like the guy below!

En mann med munnen åpen og hendene på et tastatur

Also, please rely on the scheduled job, if you can. But in some scenarios, you'll have to do the dirty work yourself.

That's it!

 

Update: A comment from Optimizely employee Quan Mai:
https://vimvq1987.com/delete-a-content-the-right-way/

Found this post helpful? Help keep this blog ad-free by buying me a coffee! ☕