Ektron Rename Templates

| | | | |

This script will rename template paths

SET XACT_ABORT ON

DECLARE @currval NVARCHAR(500)
DECLARE @newval NVARCHAR(500)
DECLARE @search NVARCHAR(500)
DECLARE @replace NVARCHAR(500)

SET @search = '/Index.aspx' --string to find
SET @replace = '/Default.aspx' --replacement string

DECLARE @pos INT
DECLARE @id BIGINT

BEGIN TRAN

DECLARE curs CURSOR LOCAL FAST_FORWARD
FOR
SELECT template_id
	,template_filename
FROM templates_tbl
WHERE template_filename LIKE '%' + @search + '%'

OPEN curs

FETCH NEXT
FROM curs
INTO @id
	,@currval

WHILE @@fetch_status = 0
BEGIN
	PRINT 'Url before update=' + @currval

	SET @newval = replace(@currval, @search, @replace)

	UPDATE templates_tbl
	SET template_filename = @newval
	WHERE template_id = @id

	PRINT 'Value after update=' + @newval

	FETCH NEXT
	FROM curs
	INTO @id
		,@currval
END

CLOSE curs

DEALLOCATE curs

ROLLBACK TRAN
	--commit tran

Source: http://www.skonet.com/Articles_Archive/Helpful_Sql_Scripts_for_Ektron_CMS_400_Net.aspx

Originally Posted on October 23, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.