Two options with this fix, official script from Ektron or to fix the individual tables that are currently having the issue.
CREATE PROCEDURE [dbo].[fixmaxentries] AS BEGIN UPDATE max_entries SET max_table_number = ( SELECT MAX(PreferenceId) + 2 FROM notification_preference ) WHERE table_name = 'notification_preference'; UPDATE max_entries SET max_table_number = ( SELECT MAX(PreferenceId) + 2 FROM notification_preference_default ) WHERE table_name = 'notification_preference_default'; END
exec fixmaxentries
Individual Table(s)
Update
max_entries
SET
max_table_number = (
SELECT
MAX(PreferenceId)
FROM
notification_preference
)
WHERE
table_name = 'notification_preference'
Update
max_entries
SET
max_table_number = (
SELECT
MAX(PreferenceId)
FROM
notification_preference_default
)
WHERE
table_name = 'notification_preference_default'
SELECT TOP 1000 [table_name]
,[max_table_number]
FROM [max_entries]
Official fix from Ektron, specific to 8.0.2
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_fixmaxentries]') AND type in (N'P', N'PC'))
drop procedure [dbo].[cms_fixmaxentries]
go
create procedure [dbo].[cms_fixmaxentries]
as
begin
begin try
begin tran;
declare @serverindex bigint
select @serverindex =ISNULL(server_index,1) from settings
if(@serverindex >0)
begin
declare @tbl table(tablename nvarchar(255) not null primary key clustered,columnname nvarchar(100))
insert into @tbl(tablename,columnname )
select t.table_name ,column_name from (select ku.table_name,ku.ordinal_position,column_name from information_schema.table_constraints as tc inner join information_schema.key_column_usage as ku on tc.constraint_type = 'primary key' and tc.constraint_name = ku.constraint_name
where ku.TABLE_NAME not in ('dynamic_data_tbl','UrlAliasAuto_tbl','UrlAliasManual_tbl','UrlAliasRegEx_tbl','user_to_group_tbl','folder_to_template_tbl','content_edit','form_data_tbl','max_entries') and column_name not in ('ref_id','ref_type','enum_type','pref_name','flag_def_lang') and column_name not like '%language' and column_name not like '%language_id' )t join max_entries m on (t.table_name=m.table_name)
order by table_name, ordinal_position
insert into @tbl(tablename,columnname ) values('dynamic_data_tbl','id')
insert into @tbl(tablename,columnname ) values('form_data_tbl','form_data_id')
insert into @tbl(tablename,columnname ) values('UrlAliasAuto_tbl','AutoId')
insert into @tbl(tablename,columnname ) values('UrlAliasManual_tbl','AliasId')
insert into @tbl(tablename,columnname ) values('UrlAliasRegEx_tbl','RegExId')
declare @startvalue bigint,@endvalue bigint,@tname nvarchar(100),@identifier nvarchar(100),@currtbl nvarchar(100),@tablemax bigint ,@newvalue bigint,@sql nvarchar(4000)
set @startvalue=(@serverindex-1)*2147483647+1
set @endvalue=(@serverindex)*2147483647
set @tname='';
set @newvalue=@startvalue ;
while(1=1)
begin
select top 1 @tname=tablename,@identifier =columnname from @tbl where tablename >@tname order by tablename asc
if(@@rowcount>0)
begin
if(@tname='users')
set @sql='select @tablemax=max('+@identifier+') from '+@tname+' where user_id<>18611864 and user_id<>999999999 and '+@identifier+'>'+convert(varchar,@startvalue)+' and '+@identifier+'<'+convert(varchar,@endvalue)
else if (@tname='usergroups')
set @sql='select @tablemax=max('+@identifier+') from '+@tname+' where usergroup_id<>888888 and '+@identifier+'>'+convert(varchar,@startvalue)+' and '+@identifier+'<'+convert(varchar,@endvalue)
else
set @sql='select @tablemax=max('+@identifier+') from '+@tname+' where '+@identifier+'>'+convert(varchar,@startvalue)+' and '+@identifier+'<'+convert(varchar,@endvalue)
exec sp_executesql @sql ,N'@tablemax bigint out', @tablemax out
if(@tablemax>@newvalue ) set @newvalue =@tablemax
end
else break;
end
if(@newvalue>@startvalue) update max_entries set max_table_number=@newvalue+5
begin
update max_entries set max_table_number=@startvalue where max_table_number<@startvalue
end
end
commit tran;
end try
begin catch
if(@@trancount>0) rollback tran;
print @sql
declare @msg nvarchar(2000)
set @msg=ERROR_MESSAGE()
raiserror(@msg, 16, 1)
end catch
return
end
go
exec [cms_fixmaxentries]
go
Originally Posted on February 28, 2013
Last Updated on October 26, 2015
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.