Ektron Find Replace In UrlAliasManual

| | | | |

This script will rename manual aliases

set xact_abort on

declare @currval nvarchar(500)
declare @newval nvarchar(500)
declare @search nvarchar(500)
declare @replace varchar(500)

set @search = '/Index' --string to find
set @replace = '/Default' --replacement string

declare @pos int
declare @id bigint

begin tran

declare curs cursor local fast_forward
for
	select AliasId,AliasName
	from UrlAliasManual_Tbl
	where AliasName 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 UrlAliasManual_Tbl Set AliasName = @newval
	where AliasId = @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.