I work for a company called
Esendex where I help development and maintain their web projects. The main website uses a CMS called
EPiServer, allowing non-technical people to create, edit and publish web pages. The system uses custom page types that are based on real *.aspx files known as templates. The templates specify the layout of the dynamic content stored in EPiServer's database which is editable in the CMS. When a page is loaded, the template requests the data and inserts each part into the relevant position.
Pages in EPiServer only exist virtually - there is no physical file for their existence. They are simply based on one of the page types and the database keeps a record of any respective data. A single template can be used to create several pages that will all look the same but contain different information. This is a nice feature but what happens if a page is created against template X and we want to use template Y in the future? We asked the same question to an EPiServer specialist who didn't really have an answer. The best he could come up was to update the database manually; in other words - there is no built-in functionality. Below is some SQL that can be run against the EPiServer database in order to modify an existing page's page type:
declare @PageID int
set @PageID = X
declare @PageTypeID int
set @PageTypeID = Y
declare @LinkURL nvarchar( 255 )
select @LinkURL = [Filename] from tblPageType where pkID = @PageTypeID
set @LinkURL = @LinkURL + '?id=' + cast( @PageID as nvarchar )
update tblPage set fkPageTypeID = @PageTypeID, LinkURL = @LinkURL where pkID = @PageID
update tblWorkPage set LinkURL = @LinkURL where fkPageID = @PageID
delete from tblWorkProperty
where fkWorkPageID in ( select pkID from tblWorkPage where fkPageID = @PageID )
Simply replace X with the page ID and Y with the page type ID.