How-to: Delete dangling files from a Community Server database

The other day I came across a bug when upgrading my site to Community Server 2008. The Community Server 2008 upgrade tool would throw an exception when trying to move my files into CFS. The exception was result of the upgrade tool trying to pull down post attachments where the Section or Post didn't exist.

This might not seem like such a bad thing, but it is for two reasons:

  1. You have a file that is taking up database space that isn’t accessible within Community Server.
  2. Community Server appends the SectionID to file name. Since the SectionID is null an exception will be thrown when creating the file name.

I created the following SQL statement that will delete all cs_PostAttachments where the SectionID and ApplicationType is NULL and the section doesn't exist in the cs_sections table.

    cs_Sections.SectionID = cs_PostAttachments.SectionID
    cs_PostAttachments.Content NOT LIKE 0x AND
    cs_Sections.SectionID IS NULL AND
    cs_Sections.ApplicationType IS NULL

-Blake Niemyjski

Posted Apr 27 2008, 01:13 PM by Blake Niemyjski |


Top 10 Contributor
Joined on 08-19-2007
Columbia Station, Ohio
re: How-to: Delete dangling files from a Community Server database Posted on May 06 2008, 03:10 PM

w00t!  Added to my scripts collection. Did you ping the dev team on this?  Let me know and I can pass it along if you haven't already.

Și astfel am upgradat softul de comunitate pe RONUA.RO Posted on Jan 20 2009, 05:17 PM;
Copyright © 2008 Windows Coding
Microsoft and Microsoft logo's are trademarks of Microsoft Corporation.