解决方案: |
可以把GL_ACCASS表用SELECT * FROM GL_ACCASS INTO GL_ACCASSNEW 的方法导到新表中,把原表生成相关索引和关系语句脚本后,删去原表,再把新生成的表改名GL_ACCASS,用脚本把索引和关系创建后,等于把原来的错误排开,再进行正常记帐,就无问题。 相关脚本: ALTER TABLE [dbo].[GL_accass] ADD CONSTRAINT [aaaaaGL_accass_PK] PRIMARY KEY NONCLUSTERED ( [i_id] ) ON [PRIMARY] GO CREATE INDEX [ccode] ON [dbo].[GL_accass]([ccode], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_cus] ON [dbo].[GL_accass]([ccode], [ccus_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_cus_dept] ON [dbo].[GL_accass]([ccode], [ccus_id], [cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_cus_item] ON [dbo].[GL_accass]([ccode], [ccus_id], [citem_class], [citem_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_dept] ON [dbo].[GL_accass]([ccode], [cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_item] ON [dbo].[GL_accass]([ccode], [citem_class], [citem_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_item_dept] ON [dbo].[GL_accass]([ccode], [citem_class], [citem_id], [cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_person] ON [dbo].[GL_accass]([ccode], [cdept_id], [cperson_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_post] ON [dbo].[GL_accass]([ccode], [cdept_id], [cperson_id], [ccus_id], [csup_id], [citem_class], [citem_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_sup] ON [dbo].[GL_accass]([ccode], [csup_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_sup_dept] ON [dbo].[GL_accass]([ccode], [csup_id], [cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [ccode_sup_item] ON [dbo].[GL_accass]([ccode], [csup_id], [citem_class], [citem_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [cexch_name] ON [dbo].[GL_accass]([cexch_name]) ON [PRIMARY] GO CREATE INDEX [customer] ON [dbo].[GL_accass]([ccus_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [CustomerGL_accass] ON [dbo].[GL_accass]([ccus_id]) ON [PRIMARY] GO CREATE INDEX [DepartmentGL_accass] ON [dbo].[GL_accass]([cdept_id]) ON [PRIMARY] GO CREATE INDEX [dept] ON [dbo].[GL_accass]([cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [item] ON [dbo].[GL_accass]([citem_class], [citem_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [item_dept] ON [dbo].[GL_accass]([citem_class], [citem_id], [cdept_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [person] ON [dbo].[GL_accass]([cdept_id], [cperson_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [PersonGL_accass] ON [dbo].[GL_accass]([cperson_id]) ON [PRIMARY] GO CREATE INDEX [supplier] ON [dbo].[GL_accass]([csup_id], [iperiod]) ON [PRIMARY] GO CREATE INDEX [VendorGL_accass] ON [dbo].[GL_accass]([csup_id]) ON [PRIMARY] GO setuser GO EXEC sp_bindefault N'[dbo].[GL_accass_mb_D]', N'[GL_accass].[mb]' GO EXEC sp_bindefault N'[dbo].[GL_accass_mb_f_D]', N'[GL_accass].[mb_f]' GO EXEC sp_bindefault N'[dbo].[GL_accass_mc_D]', N'[GL_accass].[mc]' GO EXEC sp_bindefault N'[dbo].[GL_accass_mc_f_D]', N'[GL_accass].[mc_f]' GO EXEC sp_bindefault N'[dbo].[GL_accass_md_D]', N'[GL_accass].[md]' GO EXEC sp_bindefault N'[dbo].[GL_accass_md_f_D]', N'[GL_accass].[md_f]' GO EXEC sp_bindefault N'[dbo].[GL_accass_me_D]', N'[GL_accass].[me]' GO EXEC sp_bindefault N'[dbo].[GL_accass_me_f_D]', N'[GL_accass].[me_f]' GO EXEC sp_bindefault N'[dbo].[GL_accass_nb_s_D]', N'[GL_accass].[nb_s]' GO EXEC sp_bindefault N'[dbo].[GL_accass_nc_s_D]', N'[GL_accass].[nc_s]' GO EXEC sp_bindefault N'[dbo].[GL_accass_nd_s_D]', N'[GL_accass].[nd_s]' GO EXEC sp_bindefault N'[dbo].[GL_accass_ne_s_D]', N'[GL_accass].[ne_s]' GO setuser GO ALTER TABLE [dbo].[GL_accass] ADD CONSTRAINT [FK__GL_accass__ccus___22C00386] FOREIGN KEY ( [ccus_id] ) REFERENCES [dbo].[Customer] ( [cCusCode] ), FOREIGN KEY ( [cdept_id] ) REFERENCES [dbo].[Department] ( [cDepCode] ), FOREIGN KEY ( [cperson_id] ) REFERENCES [dbo].[Person] ( [cPersonCode] ), CONSTRAINT [FK__GL_accass__csup___5BC376B8] FOREIGN KEY ( [csup_id] ) REFERENCES [dbo].[Vendor] ( [cVenCode] ) 以上处理后,再次修复数据库无错误。 对于对帐不平,因为9月底对帐正确,可以用反记帐到10月期初的方法解决,整理辅助总帐表GL_ACCASS表,使之与9月底的状态一致. |