Sat,
If you run this script, does everything come out alright?
/* This script will find incorrect account framework in all company databases in the
GL10110, GL10111, GL70500, GL70501, GL00100, and GL00201 tables. */
/*Script Revised: 4/21/2010*/
/*Script Revised: 3/5/2013 - Added GL00100 and GL00201 tables.*/
--COPY AND REPLACE DYNAMICS WITH THE NAME OF YOUR SYSTEM DATABASE
--drop table ##Results
create table ##Results (Results char(100))
declare @dbname char(5), @TableName char(64), @ColumnName char(64), @statement char(1400)
declare FindBadAccountFrameWork cursor for
select b.INTERID,a.name,'ACTNUMBR%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL10110' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'ACTNUMBR%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL10111' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'STACCNUM%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL70500' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'EDGACNUM%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL70500' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'STACCNUM%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL70501' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'EDGACNUM%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL70501' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'ACTNUMBR%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL00100' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'ACTNUMBR%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'GL00201' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'STTACNUM%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'IV70500' and b.INTERID in (select name from master..sysdatabases)
union select b.INTERID,a.name,'EACCNBR%' from sysobjects a, DYNAMICS..SY01500 b
where a.type='U' and a.name = 'IV70500' and b.INTERID in (select name from master..sysdatabases)
order by b.INTERID,a.name
set nocount on
open FindBadAccountFrameWork
fetch next from FindBadAccountFrameWork into @dbname, @TableName, @ColumnName
while (@@fetch_status <> -1) begin
set @statement = '
declare @ActLenTable table (Segment char(15),SegLength smallint,tablename char(16), DEX_ROW_ID int identity(1,1))
declare @numseg smallint, @x smallint, @rcount smallint
select @rcount=count(a.name) from ' + rtrim(@dbname) + '..syscolumns a join ' + rtrim(@dbname) + '..sysobjects b on a.id=b.id
where b.name=''' + rtrim(@TableName) + ''' and b.type=''U'' and a.name like ''' + rtrim(@ColumnName) + '''
if (@rcount <> (select MXNUMSEG from DYNAMICS..SY003001))begin
insert into ##Results (Results) select ''Database ' + rtrim(@dbname) + ' has incorrect number of Segments in table '
+ rtrim(@TableName) + ' with the ' + substring(@ColumnName,1,8) + ' columns.''
end
insert into @ActLenTable (Segment, SegLength, tablename)
select a.name,a.length,b.name from ' + rtrim(@dbname) + '..syscolumns a join ' + rtrim(@dbname) + '..sysobjects b on a.id=b.id
where b.name=''' + rtrim(@TableName) + ''' and b.type=''U'' and a.name like ''' + rtrim(@ColumnName) + ''' order by colid
select @numseg=count(*) from @ActLenTable
set @x=1
while (@x <= @numseg) begin
if (select SegLength from @ActLenTable where DEX_ROW_ID=@x) = (select SGMNTLTH from DYNAMICS..SY00302 where SGMTNUMB = @x) or
(select SegLength from @ActLenTable where DEX_ROW_ID=@x) = ((select SGMNTLTH from DYNAMICS..SY00302 where SGMTNUMB = @x)+1) begin
set @x=@x
end
else begin
insert into ##Results (Results)
select ''Database ' + rtrim(@dbname) + ', Segment '' + rtrim(cast(@x as char(2))) + '' has the incorrect length in table '
+ rtrim(@TableName) + ' with the ' + substring(@ColumnName,1,8) + ' columns.''
end
set @x=@x+1
end
'
exec (@statement)
fetch next from FindBadAccountFrameWork into @dbname, @TableName, @ColumnName
end
deallocate FindBadAccountFrameWork
select * from ##Results
drop table ##Results
Kind regards,
Leslie