Make truncate by ignoring the foreing key

0
  

Can not truncate table 'ARITREINAMENTO.glo.tbEndereco' because it is   being referenced by a FOREIGN KEY constraint.

Truncate has already been run in the agency table that references the address that is, there are only addresses in the table that are not referenced by any other table

I want to make truncate in both to restart the records and there are no inconsistencies (Agencies without addresses and no addresses without agencies)

    
asked by anonymous 22.12.2017 / 13:28

1 answer

1

The alternative I found was to delete all records from the table and restart auto_increment

delete from tbEndereco where id < maxID+1
DBCC CHECKIDENT (tbEndereco, RESEED, 0)

Note: delete only worked because no record was referenced by another table

.

    
22.12.2017 / 14:15