Tag Archives: SQL

Rebuilding the Orchard Blog Archive List

I imported this blog into Orchard using the BlogML module and it worked great except for one thing. The archive list showed that all the items were published the day I uploaded the blog instead of when each post was originally posted. Here is some SQL you can use to fix this just in case you need it.

DECLARE @BlogPart_id int = 16

DELETE FROM Orchard_Blogs_BlogPartArchiveRecord 
	WHERE BlogPart_id = @BlogPart_id

INSERT INTO Orchard_Blogs_BlogPartArchiveRecord
	SELECT YEAR(CreatedUtc) Year, MONTH(CreatedUtc) Month, COUNT(*) PostCount, @BlogPart_id BlogPart_id
	FROM Common_CommonPartRecord 
	WHEREwhere Container_id = @BlogPart_id
	GROUP BY YEAR(CreatedUtc), MONTH(CreatedUtc)
	ORDER BY YEAR(CreatedUtc), MONTH(CreatedUtc)