"Leftover" images

claus.vestergaard
Member since: 2008
 

In my development environment I have som images created by a now deleted user. These images causes exceptions to be thrown when I try to access the image gallery.

How can I get rid of these images without ruining the database? 

#31001 Jun 30, 2009 9:54
  • tost
    Member since: 2007
     

    Hi Claus,

    These images should have been removed when the user was removed. But anyways... First run this SQL script:

    DELETE FROM tblEPiServerCommunityImageGalleryImage
    WHERE intUploaderID NOT IN (SELECT intID FROM tblEPiServerCommonUser)

     

    This will delete all the images. Then you will probably have to update the counters on the image galleries as well. This is done with the following scripts:

    UPDATE tblEPiServerCommunityImageGallery
    SET intNumOfImagesTotal =
    (SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
    WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID)

    UPDATE tblEPiServerCommunityImageGallery
    SET intNumOfImagesPublished =
    (SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
    WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID
    AND intPublishState = 1
    )

    UPDATE tblEPiServerCommunityImageGallery
    SET intNumOfImagesNotPublished =
    (SELECT COUNT(*) FROM tblEPiServerCommunityImageGalleryImage
    WHERE intImageGalleryID = tblEPiServerCommunityImageGallery.intID
    AND intPublishState = 2
    )

    Probably best to take a backup of database before you this, just in case ;)

    Best regards,
    Tom

     

    #31080 Jul 01, 2009 15:04
  • claus.vestergaard
    Member since: 2008
     

    Great! Thanks, Tom.

    Best regards

    Claus

    #31152 Jul 06, 2009 13:26
  • claus.vestergaard
    Member since: 2008
     

    Great! Thanks, Tom.

    Best regards

    Claus

    #31153 Jul 06, 2009 13:26